home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / netbsd / incoming / isa-950822.diff < prev    next >
Text File  |  1995-11-21  |  496KB  |  17,599 lines

  1. *** old-NetBSD/src/bin/stty/key.c
  2. --- NetBSD/src/bin/stty/key.c
  3. ***************
  4. *** 67,72 ****
  5. --- 67,74 ----
  6.   void    f_sane __P((struct info *));
  7.   void    f_size __P((struct info *));
  8.   void    f_speed __P((struct info *));
  9. + void    f_ostart __P((struct info *));
  10. + void    f_ostop __P((struct info *));
  11.   void    f_tty __P((struct info *));
  12.   __END_DECLS
  13.   
  14. ***************
  15. *** 90,95 ****
  16. --- 92,99 ----
  17.       { "nl",        f_nl,        F_OFFOK },
  18.       { "old",    f_tty,        0 },
  19.       { "ospeed",    f_ospeed,    F_NEEDARG },
  20. +     { "ostart",    f_ostart,    0 },
  21. +     { "ostop",    f_ostop,    0 },
  22.       { "raw",    f_raw,        F_OFFOK },
  23.       { "rows",    f_rows,        F_NEEDARG },
  24.       { "sane",    f_sane,        0 },
  25. ***************
  26. *** 302,305 ****
  27. --- 306,325 ----
  28.       tmp = TTYDISC;
  29.       if (ioctl(0, TIOCSETD, &tmp) < 0)
  30.           err(1, "TIOCSETD");
  31. + }
  32. + void
  33. + f_ostart(ip)
  34. +     struct info *ip;
  35. + {
  36. +     if (ioctl (0, TIOCSTART) < 0)
  37. +         err(1, "TIOCSTART");
  38. + }
  39. + void
  40. + f_ostop(ip)
  41. +     struct info *ip;
  42. + {
  43. +     if (ioctl (0, TIOCSTOP) < 0)
  44. +         err(1, "TIOCSTOP");
  45.   }
  46. *** old-NetBSD/src/gnu/lib/libg++/iostream/stdstrbufs.C
  47. --- NetBSD/src/gnu/lib/libg++/iostream/stdstrbufs.C
  48. ***************
  49. *** 53,62 ****
  50. --- 53,70 ----
  51.   #define vt_filebuf __vtbl__7filebuf
  52.   extern char vt_filebuf[1];
  53.   #elif _G_DOLLAR_IN_LABEL
  54. + #if __GNUC_MINOR__ >= 5        // XXX I'm not sure it was introduced in 2.5
  55. + extern char vt_filebuf[1] asm(UNDERSCORE "_vt$7filebuf");
  56. + #else
  57.   extern char vt_filebuf[1] asm(UNDERSCORE "_vt$filebuf");
  58. + #endif
  59. + #else
  60. + #if __GNUC_MINOR__ >= 5        // XXX I'm not sure it was introduced in 2.5
  61. + extern char vt_filebuf[1] asm(UNDERSCORE "_vt.7filebuf");
  62.   #else
  63.   extern char vt_filebuf[1] asm(UNDERSCORE "_vt.filebuf");
  64.   #endif
  65. + #endif
  66.   #endif /* !defined(vt_filebuf) */
  67.   
  68.   struct _fake_filebuf {
  69. ***************
  70. *** 85,93 ****
  71. --- 93,109 ----
  72.   #define vt_stdiobuf __vtbl__8stdiobuf
  73.   extern char vt_stdiobuf[1];
  74.   #elif _G_DOLLAR_IN_LABEL
  75. + #if __GNUC_MINOR__ >= 5        // XXX I'm not sure it was introduced in 2.5
  76. + extern char vt_stdiobuf[1] asm(UNDERSCORE "_vt$8stdiobuf");
  77. + #else
  78.   extern char vt_stdiobuf[1] asm(UNDERSCORE "_vt$stdiobuf");
  79. + #endif
  80. + #else
  81. + #if __GNUC_MINOR__ >= 5        // XXX I'm not sure it was introduced in 2.5
  82. + extern char vt_stdiobuf[1] asm(UNDERSCORE "_vt.8stdiobuf");
  83.   #else
  84.   extern char vt_stdiobuf[1] asm(UNDERSCORE "_vt.stdiobuf");
  85. + #endif
  86.   #endif
  87.   #endif /* !defined(vt_stdiobuf) */
  88.   
  89. *** old-NetBSD/src/gnu/lib/libg++/iostream/strstream.C
  90. --- NetBSD/src/gnu/lib/libg++/iostream/strstream.C
  91. ***************
  92. *** 144,150 ****
  93.       // This can lose in pathological cases (ptr near the end
  94.       // of the address space).  A better solution might be to
  95.       // adjust the size on underflow/overflow.  FIXME.
  96. !     for (int s; s = 2*size, s > 0 && ptr + s > ptr && s < 0x4000000L; )
  97.           size = s;
  98.       size = s;
  99.   #else
  100. --- 144,151 ----
  101.       // This can lose in pathological cases (ptr near the end
  102.       // of the address space).  A better solution might be to
  103.       // adjust the size on underflow/overflow.  FIXME.
  104. !     int s;
  105. !     for (; s = 2*size, s > 0 && ptr + s > ptr && s < 0x4000000L; )
  106.           size = s;
  107.       size = s;
  108.   #else
  109. *** old-NetBSD/src/gnu/lib/libg++/libg++/ACG.cc
  110. --- NetBSD/src/gnu/lib/libg++/libg++/ACG.cc
  111. ***************
  112. *** 188,194 ****
  113.       //    Determine the size of the state table
  114.       //
  115.       
  116. !     for (register int l = 0;
  117.        randomStateTable[l][0] != -1 && randomStateTable[l][1] < size;
  118.        l++);
  119.       
  120. --- 188,195 ----
  121.       //    Determine the size of the state table
  122.       //
  123.       
  124. !     register int l;
  125. !     for (l = 0;
  126.        randomStateTable[l][0] != -1 && randomStateTable[l][1] < size;
  127.        l++);
  128.       
  129. *** old-NetBSD/src/gnu/lib/libg++/libg++/Fix.cc
  130. --- NetBSD/src/gnu/lib/libg++/libg++/Fix.cc
  131. ***************
  132. *** 225,231 ****
  133.       longer = y, shorter = x;
  134.     if ( r == NULL )
  135.       r = new_Fix(longer->len);
  136. !   for ( int i=r->siz-1; i >= longer->siz; i-- )
  137.       r->s[i] = 0;
  138.     for ( ; i >= shorter->siz; i-- )
  139.       r->s[i] = longer->s[i];
  140. --- 225,232 ----
  141.       longer = y, shorter = x;
  142.     if ( r == NULL )
  143.       r = new_Fix(longer->len);
  144. !   int i;
  145. !   for ( i=r->siz-1; i >= longer->siz; i-- )
  146.       r->s[i] = 0;
  147.     for ( ; i >= shorter->siz; i-- )
  148.       r->s[i] = longer->s[i];
  149. ***************
  150. *** 251,257 ****
  151.       longer = y, shorter = x;
  152.     if ( r == NULL )
  153.       r = new_Fix(longer->len);
  154. !   for ( int i=r->siz-1; i >= longer->siz; i-- )
  155.       r->s[i] = 0;
  156.     for ( ; i >= shorter->siz; i-- )
  157.       r->s[i] = (longer == x ? x->s[i] : -y->s[i]);
  158. --- 252,259 ----
  159.       longer = y, shorter = x;
  160.     if ( r == NULL )
  161.       r = new_Fix(longer->len);
  162. !   int i;
  163. !   for ( i=r->siz-1; i >= longer->siz; i-- )
  164.       r->s[i] = 0;
  165.     for ( ; i >= shorter->siz; i-- )
  166.       r->s[i] = (longer == x ? x->s[i] : -y->s[i]);
  167. ***************
  168. *** 279,285 ****
  169.       x = negate(x,X.rep);
  170.     if ( ysign )
  171.       y = negate(y,Y.rep);
  172. !   for ( int i=0; i < r->siz; i++ )
  173.       r->s[i] = 0;
  174.     for ( i=x->siz-1; i >= 0; i-- )
  175.     {
  176. --- 281,288 ----
  177.       x = negate(x,X.rep);
  178.     if ( ysign )
  179.       y = negate(y,Y.rep);
  180. !   int i;
  181. !   for ( i=0; i < r->siz; i++ )
  182.       r->s[i] = 0;
  183.     for ( i=x->siz-1; i >= 0; i-- )
  184.     {
  185. ***************
  186. *** 310,316 ****
  187.       (*Fix_range_error_handler)("multiply by int -- int too large");
  188.     if ( r == NULL )
  189.       r = new_Fix(x->len);
  190. !   for ( int i=r->siz-1; i >= x->siz; i-- )
  191.       r->s[i] = 0;
  192.     int32 a, carry = 0;
  193.     for ( ; i > 0; i-- )
  194. --- 313,320 ----
  195.       (*Fix_range_error_handler)("multiply by int -- int too large");
  196.     if ( r == NULL )
  197.       r = new_Fix(x->len);
  198. !   int i;
  199. !   for ( i=r->siz-1; i >= x->siz; i-- )
  200.       r->s[i] = 0;
  201.     int32 a, carry = 0;
  202.     for ( ; i > 0; i-- )
  203. ***************
  204. *** 418,424 ****
  205.   
  206.     int xr = 16 - xl;
  207.     uint16 xrmask = 0xffffL >> xr;
  208. !   for ( int i=0; i < ilow; i++, rs+=u, xsl+=u, xsr+=u )
  209.       *rs = 0;
  210.     for ( ; i < ihigh; i++, rs+=u, xsl+=u, xsr+=u )
  211.       *rs = (*xsl << xl) + ((*xsr >> xr) & xrmask);
  212. --- 422,429 ----
  213.   
  214.     int xr = 16 - xl;
  215.     uint16 xrmask = 0xffffL >> xr;
  216. !   int i;
  217. !   for ( i=0; i < ilow; i++, rs+=u, xsl+=u, xsr+=u )
  218.       *rs = 0;
  219.     for ( ; i < ihigh; i++, rs+=u, xsl+=u, xsr+=u )
  220.       *rs = (*xsl << xl) + ((*xsr >> xr) & xrmask);
  221. ***************
  222. *** 434,440 ****
  223.     if ( r == NULL )
  224.       r = new_Fix(x->len);
  225.     uint32 carry = 1;
  226. !   for ( int i=r->siz-1; i >= x->siz; i-- )
  227.       r->s[i] = 0;
  228.     for ( ; i >= 0; i-- )
  229.     {
  230. --- 439,446 ----
  231.     if ( r == NULL )
  232.       r = new_Fix(x->len);
  233.     uint32 carry = 1;
  234. !   int i;
  235. !   for ( i=r->siz-1; i >= x->siz; i-- )
  236.       r->s[i] = 0;
  237.     for ( ; i >= 0; i-- )
  238.     {
  239. *** old-NetBSD/src/gnu/lib/libg++/libg++/Fix.h
  240. --- NetBSD/src/gnu/lib/libg++/libg++/Fix.h
  241. ***************
  242. *** 54,60 ****
  243.   
  244.   public:
  245.             Fix();
  246. !                   Fix(Fix&);
  247.             Fix(double);
  248.                     Fix(int);
  249.                     Fix(int, const Fix&);
  250. --- 54,60 ----
  251.   
  252.   public:
  253.             Fix();
  254. !                   Fix(const Fix&);
  255.             Fix(double);
  256.                     Fix(int);
  257.                     Fix(int, const Fix&);
  258. ***************
  259. *** 199,205 ****
  260.   {
  261.     uint16 *ts = to->s, *fs = from->s;
  262.     int ilim = to->siz < from->siz ? to->siz : from->siz;
  263. !   for ( int i=0; i < ilim; i++ )
  264.       *ts++ = *fs++;
  265.     for ( ; i < to->siz; i++ )
  266.       *ts++ = 0;
  267. --- 199,206 ----
  268.   {
  269.     uint16 *ts = to->s, *fs = from->s;
  270.     int ilim = to->siz < from->siz ? to->siz : from->siz;
  271. !   int i;
  272. !   for ( i=0; i < ilim; i++ )
  273.       *ts++ = *fs++;
  274.     for ( ; i < to->siz; i++ )
  275.       *ts++ = 0;
  276. ***************
  277. *** 229,235 ****
  278.     rep = new_Fix(Fix_default_length,d);
  279.   }
  280.   
  281. ! inline Fix::Fix(Fix&  y)
  282.   {
  283.     rep = y.rep; rep->ref++;
  284.   }
  285. --- 230,236 ----
  286.     rep = new_Fix(Fix_default_length,d);
  287.   }
  288.   
  289. ! inline Fix::Fix(const Fix&  y)
  290.   {
  291.     rep = y.rep; rep->ref++;
  292.   }
  293. *** old-NetBSD/src/gnu/lib/libg++/libg++/Fix24.h
  294. --- NetBSD/src/gnu/lib/libg++/libg++/Fix24.h
  295. ***************
  296. *** 355,361 ****
  297.   
  298.   inline Fix24 operator>>(const Fix24& a, int b)     
  299.   { 
  300. !   return (a.m >> b) & 0xffffff00L; 
  301.   }
  302.   
  303.   inline  Fix24&  Fix24:: operator+=(const Fix24&  f)
  304. --- 355,361 ----
  305.   
  306.   inline Fix24 operator>>(const Fix24& a, int b)     
  307.   { 
  308. !   return (a.m >> b) & (long)0xffffff00L; 
  309.   }
  310.   
  311.   inline  Fix24&  Fix24:: operator+=(const Fix24&  f)
  312. *** old-NetBSD/src/gnu/lib/libg++/libg++/Integer.cc
  313. --- NetBSD/src/gnu/lib/libg++/libg++/Integer.cc
  314. ***************
  315. *** 1882,1888 ****
  316.     long k = 0;
  317.     int l = (ul <= vl)? ul : vl;
  318.     int cont = 1;
  319. !   for (int i = 0;  i < l && cont; ++i)
  320.     {
  321.       unsigned long a =  (i < ul)? u->s[i] : 0;
  322.       unsigned long b =  (i < vl)? v->s[i] : 0;
  323. --- 1882,1889 ----
  324.     long k = 0;
  325.     int l = (ul <= vl)? ul : vl;
  326.     int cont = 1;
  327. !   int i;
  328. !   for (i = 0;  i < l && cont; ++i)
  329.     {
  330.       unsigned long a =  (i < ul)? u->s[i] : 0;
  331.       unsigned long b =  (i < vl)? v->s[i] : 0;
  332. *** old-NetBSD/src/gnu/lib/libg++/libg++/Obstack.cc
  333. --- NetBSD/src/gnu/lib/libg++/libg++/Obstack.cc
  334. ***************
  335. *** 85,91 ****
  336.   
  337.   int Obstack::contains(void* obj) // true if obj somewhere in Obstack
  338.   {
  339. !   for (_obstack_chunk* ch = chunk; 
  340.          ch != 0 && (obj < (void*)ch || obj >= (void*)(ch->limit)); 
  341.          ch = ch->prev);
  342.   
  343. --- 85,92 ----
  344.   
  345.   int Obstack::contains(void* obj) // true if obj somewhere in Obstack
  346.   {
  347. !   _obstack_chunk* ch;
  348. !   for (ch = chunk; 
  349.          ch != 0 && (obj < (void*)ch || obj >= (void*)(ch->limit)); 
  350.          ch = ch->prev);
  351.   
  352. *** old-NetBSD/src/gnu/lib/libg++/libg++/String.cc
  353. --- NetBSD/src/gnu/lib/libg++/libg++/String.cc
  354. ***************
  355. *** 965,971 ****
  356.   {
  357.     String sep = separator;
  358.     int xlen = 0;
  359. !   for (int i = 0; i < n; ++i)
  360.       xlen += src[i].length();
  361.     xlen += (n - 1) * sep.length();
  362.   
  363. --- 965,972 ----
  364.   {
  365.     String sep = separator;
  366.     int xlen = 0;
  367. !   int i;
  368. !   for (i = 0; i < n; ++i)
  369.       xlen += src[i].length();
  370.     xlen += (n - 1) * sep.length();
  371.   
  372. ***************
  373. *** 1117,1123 ****
  374.     const char* topx = &(xchars[x.length()]);
  375.     const char* ys = &(ychars[startpos]);
  376.     const char* topy = &(ychars[y.length()]);
  377. !   for (int l = 0; xs < topx && ys < topy && *xs++ == *ys++; ++l);
  378.     r.rep = Salloc(r.rep, ss, l, l);
  379.   }
  380.   
  381. --- 1118,1125 ----
  382.     const char* topx = &(xchars[x.length()]);
  383.     const char* ys = &(ychars[startpos]);
  384.     const char* topy = &(ychars[y.length()]);
  385. !   int l;
  386. !   for (l = 0; xs < topx && ys < topy && *xs++ == *ys++; ++l);
  387.     r.rep = Salloc(r.rep, ss, l, l);
  388.   }
  389.   
  390. ***************
  391. *** 1129,1135 ****
  392.     const char* botx = xchars;
  393.     const char* ys = &(ychars[y.length() + startpos]);
  394.     const char* boty = ychars;
  395. !   for (int l = 0; xs >= botx && ys >= boty && *xs == *ys ; --xs, --ys, ++l);
  396.     r.rep = Salloc(r.rep, ++xs, l, l);
  397.   }
  398.   
  399. --- 1131,1138 ----
  400.     const char* botx = xchars;
  401.     const char* ys = &(ychars[y.length() + startpos]);
  402.     const char* boty = ychars;
  403. !   int l;
  404. !   for (l = 0; xs >= botx && ys >= boty && *xs == *ys ; --xs, --ys, ++l);
  405.     r.rep = Salloc(r.rep, ++xs, l, l);
  406.   }
  407.   
  408. *** old-NetBSD/src/gnu/lib/libg++/libg++/dtoa.cc
  409. --- NetBSD/src/gnu/lib/libg++/libg++/dtoa.cc
  410. ***************
  411. *** 179,185 ****
  412.             if (ch > '5') // properly round: unavoidable propagation
  413.             {
  414.               int carry = 1;
  415. !             for (char* p = f - 1; p >= fwork && carry; --p)
  416.               {
  417.                 ++*p;
  418.                 if (*p > '9')
  419. --- 179,186 ----
  420.             if (ch > '5') // properly round: unavoidable propagation
  421.             {
  422.               int carry = 1;
  423. !         char *p;
  424. !             for (p = f - 1; p >= fwork && carry; --p)
  425.               {
  426.                 ++*p;
  427.                 if (*p > '9')
  428. ***************
  429. *** 313,319 ****
  430.     char* fmtbase = (char *) _libgxx_fmtq.alloc(fmtwidth + pad + 1);
  431.     char* fmt = fmtbase;
  432.     
  433. !   for (int i = 0; i < pad; ++i) *fmt++ = ' ';
  434.     
  435.     if (is_neg) *fmt++ = '-';
  436.     
  437. --- 314,321 ----
  438.     char* fmtbase = (char *) _libgxx_fmtq.alloc(fmtwidth + pad + 1);
  439.     char* fmt = fmtbase;
  440.     
  441. !   int i;
  442. !   for (i = 0; i < pad; ++i) *fmt++ = ' ';
  443.     
  444.     if (is_neg) *fmt++ = '-';
  445.     
  446. *** old-NetBSD/src/gnu/lib/libg++/libg++/error.cc
  447. --- NetBSD/src/gnu/lib/libg++/libg++/error.cc
  448. ***************
  449. *** 20,26 ****
  450.   #endif
  451.   #include <builtin.h>
  452.   
  453. ! extern "C" _VOLATILE_VOID abort();
  454.   
  455.   _VOLATILE_VOID default_one_arg_error_handler(const char* msg)
  456.   {
  457. --- 20,26 ----
  458.   #endif
  459.   #include <builtin.h>
  460.   
  461. ! extern "C" void abort();
  462.   
  463.   _VOLATILE_VOID default_one_arg_error_handler(const char* msg)
  464.   {
  465. *** /dev/null
  466. --- NetBSD/src/gnu/usr.bin/groff/Makefile.inc
  467. ***************
  468. *** 0 ****
  469. --- 1,3 ----
  470. + #    $NetBSD: Makefile.inc,v 1.1 1995/08/10 09:08:54 niklas Exp $
  471. + LINK=        $(CXX)
  472. *** old-NetBSD/src/gnu/usr.bin/groff/addftinfo/addftinfo.cc
  473. --- NetBSD/src/gnu/usr.bin/groff/addftinfo/addftinfo.cc
  474. ***************
  475. *** 34,40 ****
  476.   static void usage();
  477.   static void convert_font(const font_params &, FILE *, FILE *);
  478.   
  479. ! typedef font_params::*param_t;
  480.   
  481.   static struct {
  482.     const char *name;
  483. --- 34,40 ----
  484.   static void usage();
  485.   static void convert_font(const font_params &, FILE *, FILE *);
  486.   
  487. ! typedef int font_params::*param_t;
  488.   
  489.   static struct {
  490.     const char *name;
  491. ***************
  492. *** 89,102 ****
  493.     param.comma_depth = DEFAULT_COMMA_DEPTH;
  494.     param.desc_depth = DEFAULT_DESC_DEPTH;
  495.     param.body_depth = DEFAULT_BODY_DEPTH;
  496. !   for (int i = 1; i < argc && argv[i][0] == '-'; i++) {
  497.       if (argv[i][1] == '-' && argv[i][2] == '\0') {
  498.         i++;
  499.         break;
  500.       }
  501.       if (i + 1 >= argc)
  502.         usage();
  503. !     for (int j = 0;; j++) {
  504.         if (j >= sizeof(param_table)/sizeof(param_table[0]))
  505.       fatal("parameter `%1' not recognized", argv[i] + 1);
  506.         if (strcmp(param_table[j].name, argv[i] + 1) == 0)
  507. --- 89,104 ----
  508.     param.comma_depth = DEFAULT_COMMA_DEPTH;
  509.     param.desc_depth = DEFAULT_DESC_DEPTH;
  510.     param.body_depth = DEFAULT_BODY_DEPTH;
  511. !   int i;
  512. !   for (i = 1; i < argc && argv[i][0] == '-'; i++) {
  513.       if (argv[i][1] == '-' && argv[i][2] == '\0') {
  514.         i++;
  515.         break;
  516.       }
  517.       if (i + 1 >= argc)
  518.         usage();
  519. !     int j;
  520. !     for (j = 0;; j++) {
  521.         if (j >= sizeof(param_table)/sizeof(param_table[0]))
  522.       fatal("parameter `%1' not recognized", argv[i] + 1);
  523.         if (strcmp(param_table[j].name, argv[i] + 1) == 0)
  524. *** old-NetBSD/src/gnu/usr.bin/groff/eqn/delim.cc
  525. --- NetBSD/src/gnu/usr.bin/groff/eqn/delim.cc
  526. ***************
  527. *** 276,282 ****
  528.     printf(".ds " DELIM_STRING "\n");
  529.     delimiter *d = delim_table;
  530.     int delim_len = strlen(delim);
  531. !   for (int i = 0; i < DELIM_TABLE_SIZE; i++, d++)
  532.       if (strncmp(delim, d->name, delim_len) == 0 
  533.       && (left_or_right & d->flags) != 0)
  534.         break;
  535. --- 276,283 ----
  536.     printf(".ds " DELIM_STRING "\n");
  537.     delimiter *d = delim_table;
  538.     int delim_len = strlen(delim);
  539. !   int i;
  540. !   for (i = 0; i < DELIM_TABLE_SIZE; i++, d++)
  541.       if (strncmp(delim, d->name, delim_len) == 0 
  542.       && (left_or_right & d->flags) != 0)
  543.         break;
  544. *** old-NetBSD/src/gnu/usr.bin/groff/eqn/lex.cc
  545. --- NetBSD/src/gnu/usr.bin/groff/eqn/lex.cc
  546. ***************
  547. *** 251,257 ****
  548.   
  549.   void init_table(const char *device)
  550.   {
  551. !   for (int i = 0; i < sizeof(token_table)/sizeof(token_table[0]); i++) {
  552.       definition *def = new definition;
  553.       def->is_macro = 0;
  554.       def->tok = token_table[i].token;
  555. --- 251,258 ----
  556.   
  557.   void init_table(const char *device)
  558.   {
  559. !   int i;
  560. !   for (i = 0; i < sizeof(token_table)/sizeof(token_table[0]); i++) {
  561.       definition *def = new definition;
  562.       def->is_macro = 0;
  563.       def->tok = token_table[i].token;
  564. ***************
  565. *** 472,478 ****
  566.                          char **av, input *x)
  567.   : input(x), argc(ac), ap(0)
  568.   {
  569. !   for (int i = 0; i < argc; i++)
  570.       argv[i] = av[i];
  571.     p = s = strsave(body);
  572.     int j = 0;
  573. --- 473,480 ----
  574.                          char **av, input *x)
  575.   : input(x), argc(ac), ap(0)
  576.   {
  577. !   int i;
  578. !   for (i = 0; i < argc; i++)
  579.       argv[i] = av[i];
  580.     p = s = strsave(body);
  581.     int j = 0;
  582. ***************
  583. *** 687,693 ****
  584.   {
  585.     char *argv[9];
  586.     int argc = 0;
  587. !   for (int i = 0; i < 9; i++)
  588.       argv[i] = 0;
  589.     int level = 0;
  590.     int c;
  591. --- 689,696 ----
  592.   {
  593.     char *argv[9];
  594.     int argc = 0;
  595. !   int i;
  596. !   for (i = 0; i < 9; i++)
  597.       argv[i] = 0;
  598.     int level = 0;
  599.     int c;
  600. *** old-NetBSD/src/gnu/usr.bin/groff/eqn/list.cc
  601. --- NetBSD/src/gnu/usr.bin/groff/eqn/list.cc
  602. ***************
  603. *** 174,180 ****
  604.   void list_box::compute_sublist_width(int n)
  605.   {
  606.     int total_spacing = 0;
  607. !   for (int i = 1; i < n + 1 && i < list.len; i++)
  608.       total_spacing += compute_spacing(is_script, list.p[i-1]->spacing_type,
  609.                        list.p[i]->spacing_type);
  610.     printf(".nr " TEMP_REG " %dM", total_spacing);
  611. --- 174,181 ----
  612.   void list_box::compute_sublist_width(int n)
  613.   {
  614.     int total_spacing = 0;
  615. !   int i;
  616. !   for (i = 1; i < n + 1 && i < list.len; i++)
  617.       total_spacing += compute_spacing(is_script, list.p[i-1]->spacing_type,
  618.                        list.p[i]->spacing_type);
  619.     printf(".nr " TEMP_REG " %dM", total_spacing);
  620. *** old-NetBSD/src/gnu/usr.bin/groff/grodvi/dvi.cc
  621. --- NetBSD/src/gnu/usr.bin/groff/grodvi/dvi.cc
  622. ***************
  623. *** 305,311 ****
  624.     if (env->size != cur_point_size || f != cur_font) {
  625.       cur_font = f;
  626.       cur_point_size = env->size;
  627. !     for (int i = 0;; i++) {
  628.         if (i >= FONTS_MAX) {
  629.       fatal("too many output fonts required");
  630.         }
  631. --- 305,312 ----
  632.     if (env->size != cur_point_size || f != cur_font) {
  633.       cur_font = f;
  634.       cur_point_size = env->size;
  635. !     int i;
  636. !     for (i = 0;; i++) {
  637.         if (i >= FONTS_MAX) {
  638.       fatal("too many output fonts required");
  639.         }
  640. *** old-NetBSD/src/gnu/usr.bin/groff/groff/groff.cc
  641. --- NetBSD/src/gnu/usr.bin/groff/groff/groff.cc
  642. ***************
  643. *** 50,57 ****
  644.   }
  645.   #endif /* not STDLIB_H_DECLARES_PUTENV */
  646.   
  647. - const char *strsignal(int);
  648.   const int SOELIM_INDEX = 0;
  649.   const int REFER_INDEX = SOELIM_INDEX + 1;
  650.   const int PIC_INDEX = REFER_INDEX + 1;
  651. --- 50,55 ----
  652. ***************
  653. *** 281,287 ****
  654.     commands[TROFF_INDEX].append_arg("-T", device);
  655.     commands[EQN_INDEX].append_arg("-T", device);
  656.   
  657. !   for (int first_index = 0; first_index < TROFF_INDEX; first_index++)
  658.       if (commands[first_index].get_name() != 0)
  659.         break;
  660.     if (optind < argc) {
  661. --- 279,286 ----
  662.     commands[TROFF_INDEX].append_arg("-T", device);
  663.     commands[EQN_INDEX].append_arg("-T", device);
  664.   
  665. !   int first_index;
  666. !   for (first_index = 0; first_index < TROFF_INDEX; first_index++)
  667.       if (commands[first_index].get_name() != 0)
  668.         break;
  669.     if (optind < argc) {
  670. ***************
  671. *** 349,355 ****
  672.   
  673.   void print_commands()
  674.   {
  675. !   for (int last = SPOOL_INDEX; last >= 0; last--)
  676.       if (commands[last].get_name() != 0)
  677.         break;
  678.     for (int i = 0; i <= last; i++)
  679. --- 348,355 ----
  680.   
  681.   void print_commands()
  682.   {
  683. !   int last;
  684. !   for (last = SPOOL_INDEX; last >= 0; last--)
  685.       if (commands[last].get_name() != 0)
  686.         break;
  687.     for (int i = 0; i <= last; i++)
  688. ***************
  689. *** 463,469 ****
  690.     str += ' ';
  691.     int needs_quoting = 0;
  692.     int contains_single_quote = 0;
  693. !   for (const char *p = arg; *p != '\0'; p++)
  694.       switch (*p) {
  695.       case ';':
  696.       case '&':
  697. --- 463,470 ----
  698.     str += ' ';
  699.     int needs_quoting = 0;
  700.     int contains_single_quote = 0;
  701. !   const char *p;
  702. !   for (p = arg; *p != '\0'; p++)
  703.       switch (*p) {
  704.       case ';':
  705.       case '&':
  706. *** old-NetBSD/src/gnu/usr.bin/groff/grops/ps.cc
  707. --- NetBSD/src/gnu/usr.bin/groff/grops/ps.cc
  708. ***************
  709. *** 172,178 ****
  710.   ps_output &ps_output::put_string(const char *s, int n)
  711.   {
  712.     int len = 0;
  713. !   for (int i = 0; i < n; i++) {
  714.       char c = s[i];
  715.       if (isascii(c) && isprint(c)) {
  716.         if (c == '(' || c == ')' || c == '\\')
  717. --- 172,179 ----
  718.   ps_output &ps_output::put_string(const char *s, int n)
  719.   {
  720.     int len = 0;
  721. !   int i;
  722. !   for (i = 0; i < n; i++) {
  723.       char c = s[i];
  724.       if (isascii(c) && isprint(c)) {
  725.         if (c == '(' || c == ')' || c == '\\')
  726. ***************
  727. *** 646,652 ****
  728.   void ps_printer::define_encoding(const char *encoding, int encoding_index)
  729.   {
  730.     char *vec[256];
  731. !   for (int i = 0; i < 256; i++)
  732.       vec[i] = 0;
  733.     char *path;
  734.     FILE *fp = font::open_file(encoding, &path);
  735. --- 647,654 ----
  736.   void ps_printer::define_encoding(const char *encoding, int encoding_index)
  737.   {
  738.     char *vec[256];
  739. !   int i;
  740. !   for (i = 0; i < 256; i++)
  741.       vec[i] = 0;
  742.     char *path;
  743.     FILE *fp = font::open_file(encoding, &path);
  744. ***************
  745. *** 1193,1199 ****
  746.       "invis", &ps_printer::do_invis,
  747.       "endinvis", &ps_printer::do_endinvis,
  748.     };
  749. !   for (char *p = arg; *p == ' ' || *p == '\n'; p++)
  750.       ;
  751.     char *tag = p;
  752.     for (; *p != '\0' && *p != ':' && *p != ' ' && *p != '\n'; p++)
  753. --- 1195,1202 ----
  754.       "invis", &ps_printer::do_invis,
  755.       "endinvis", &ps_printer::do_endinvis,
  756.     };
  757. !   char *p;
  758. !   for (p = arg; *p == ' ' || *p == '\n'; p++)
  759.       ;
  760.     char *tag = p;
  761.     for (; *p != '\0' && *p != ':' && *p != ' ' && *p != '\n'; p++)
  762. ***************
  763. *** 1340,1346 ****
  764.     flush_sbuf();
  765.     while (*arg == ' ' || *arg == '\n')
  766.       arg++;
  767. !   for (char *p = arg; *p != '\0' && *p != ' ' && *p != '\n'; p++)
  768.       ;
  769.     if (*p != '\0')
  770.       *p++ = '\0';
  771. --- 1343,1350 ----
  772.     flush_sbuf();
  773.     while (*arg == ' ' || *arg == '\n')
  774.       arg++;
  775. !   char *p;
  776. !   for (p = arg; *p != '\0' && *p != ' ' && *p != '\n'; p++)
  777.       ;
  778.     if (*p != '\0')
  779.       *p++ = '\0';
  780. *** old-NetBSD/src/gnu/usr.bin/groff/grops/psrm.cc
  781. --- NetBSD/src/gnu/usr.bin/groff/grops/psrm.cc
  782. ***************
  783. *** 121,127 ****
  784.                           string &version,
  785.                           unsigned revision)
  786.   {
  787. !   for (resource *r = resource_list; r; r = r->next)
  788.       if (r->type == type
  789.       && r->name == name
  790.       && r->version == version
  791. --- 121,128 ----
  792.                           string &version,
  793.                           unsigned revision)
  794.   {
  795. !   resource *r;
  796. !   for (r = resource_list; r; r = r->next)
  797.       if (r->type == type
  798.       && r->name == name
  799.       && r->version == version
  800. ***************
  801. *** 137,143 ****
  802.   
  803.   resource *resource_manager::lookup_font(const char *name)
  804.   {
  805. !   for (resource *r = resource_list; r; r = r->next)
  806.       if (r->type == RESOURCE_FONT
  807.       && strlen(name) == r->name.length()
  808.       && memcmp(name, r->name.contents(), r->name.length()) == 0)
  809. --- 138,145 ----
  810.   
  811.   resource *resource_manager::lookup_font(const char *name)
  812.   {
  813. !   resource *r;
  814. !   for (r = resource_list; r; r = r->next)
  815.       if (r->type == RESOURCE_FONT
  816.       && strlen(name) == r->name.length()
  817.       && memcmp(name, r->name.contents(), r->name.length()) == 0)
  818. ***************
  819. *** 159,172 ****
  820.   void resource_manager::document_setup(ps_output &out)
  821.   {
  822.     int nranks = 0;
  823. !   for (resource *r = resource_list; r; r = r->next)
  824.       if (r->rank >= nranks)
  825.         nranks = r->rank + 1;
  826.     if (nranks > 0) {
  827.       // Sort resource_list in reverse order of rank.
  828.       Presource *head = new Presource[nranks + 1];
  829.       Presource **tail = new Presource *[nranks + 1];
  830. !     for (int i = 0; i < nranks + 1; i++) {
  831.         head[i] = 0;
  832.         tail[i] = &head[i];
  833.       }
  834. --- 161,176 ----
  835.   void resource_manager::document_setup(ps_output &out)
  836.   {
  837.     int nranks = 0;
  838. !   resource *r;
  839. !   for (r = resource_list; r; r = r->next)
  840.       if (r->rank >= nranks)
  841.         nranks = r->rank + 1;
  842.     if (nranks > 0) {
  843.       // Sort resource_list in reverse order of rank.
  844.       Presource *head = new Presource[nranks + 1];
  845.       Presource **tail = new Presource *[nranks + 1];
  846. !     int i;
  847. !     for (i = 0; i < nranks + 1; i++) {
  848.         head[i] = 0;
  849.         tail[i] = &head[i];
  850.       }
  851. ***************
  852. *** 510,516 ****
  853.       error("missing resource type");
  854.       return 0;
  855.     }
  856. !   for (int ri = 0; ri < NRESOURCES; ri++)
  857.       if (strlen(resource_table[ri]) == *ptr - name
  858.       && memcmp(resource_table[ri], name, *ptr - name) == 0)
  859.         break;
  860. --- 514,521 ----
  861.       error("missing resource type");
  862.       return 0;
  863.     }
  864. !   int ri;
  865. !   for (ri = 0; ri < NRESOURCES; ri++)
  866.       if (strlen(resource_table[ri]) == *ptr - name
  867.       && memcmp(resource_table[ri], name, *ptr - name) == 0)
  868.         break;
  869. ***************
  870. *** 833,839 ****
  871.       do {
  872.         ++ptr;
  873.       } while (*ptr != '\0' && !white_space(*ptr));
  874. !     for (int i = 0; i < NEXTENSIONS; i++)
  875.         if (strlen(extension_table[i]) == ptr - name
  876.         && memcmp(extension_table[i], name, ptr - name) == 0) {
  877.       flags |= (1 << i);
  878. --- 838,845 ----
  879.       do {
  880.         ++ptr;
  881.       } while (*ptr != '\0' && !white_space(*ptr));
  882. !     int i;
  883. !     for (i = 0; i < NEXTENSIONS; i++)
  884.         if (strlen(extension_table[i]) == ptr - name
  885.         && memcmp(extension_table[i], name, ptr - name) == 0) {
  886.       flags |= (1 << i);
  887. ***************
  888. *** 932,938 ****
  889.         if (buf[0] == '%') {
  890.       if (buf[1] == '%') {
  891.         const char *ptr;
  892. !       for (int i = 0; i < NCOMMENTS; i++)
  893.           if (ptr = matches_comment(buf, comment_table[i].name)) {
  894.             copy_this_line
  895.           = (this->*(comment_table[i].proc))(ptr, rank, fp, outfp);
  896. --- 938,945 ----
  897.         if (buf[0] == '%') {
  898.       if (buf[1] == '%') {
  899.         const char *ptr;
  900. !       int i;
  901. !       for (i = 0; i < NCOMMENTS; i++)
  902.           if (ptr = matches_comment(buf, comment_table[i].name)) {
  903.             copy_this_line
  904.           = (this->*(comment_table[i].proc))(ptr, rank, fp, outfp);
  905. ***************
  906. *** 1028,1034 ****
  907.       return;
  908.     }
  909.     int level = 0;
  910. !   for (int i = 0; i < len; i++)
  911.       if (str[i] == '(')
  912.         level++;
  913.       else if (str[i] == ')' && --level < 0)
  914. --- 1035,1042 ----
  915.       return;
  916.     }
  917.     int level = 0;
  918. !   int i;
  919. !   for (i = 0; i < len; i++)
  920.       if (str[i] == '(')
  921.         level++;
  922.       else if (str[i] == ')' && --level < 0)
  923. *** old-NetBSD/src/gnu/usr.bin/groff/grotty/tty.cc
  924. --- NetBSD/src/gnu/usr.bin/groff/grotty/tty.cc
  925. ***************
  926. *** 218,224 ****
  927.     // characters before normal characters at each hpos, and otherwise
  928.     // in order of occurrence.
  929.   
  930. !   for (glyph **pp = lines + (vpos - 1); *pp; pp = &(*pp)->next)
  931.       if (int((*pp)->hpos) < hpos
  932.       || ((*pp)->hpos == hpos && (*pp)->draw_mode() >= g->draw_mode()))
  933.         break;
  934. --- 218,225 ----
  935.     // characters before normal characters at each hpos, and otherwise
  936.     // in order of occurrence.
  937.   
  938. !   glyph **pp;
  939. !   for (pp = lines + (vpos - 1); *pp; pp = &(*pp)->next)
  940.       if (int((*pp)->hpos) < hpos
  941.       || ((*pp)->hpos == hpos && (*pp)->draw_mode() >= g->draw_mode()))
  942.         break;
  943. ***************
  944. *** 270,276 ****
  945.     if (page_length % font::vert != 0)
  946.       error("vertical position at end of page not multiple of vertical resolution");
  947.     int lines_per_page = page_length / font::vert;
  948. !   for (int last_line = nlines; last_line > 0; last_line--)
  949.       if (lines[last_line - 1])
  950.         break;
  951.   #if 0
  952. --- 271,278 ----
  953.     if (page_length % font::vert != 0)
  954.       error("vertical position at end of page not multiple of vertical resolution");
  955.     int lines_per_page = page_length / font::vert;
  956. !   int last_line;
  957. !   for (last_line = nlines; last_line > 0; last_line--)
  958.       if (lines[last_line - 1])
  959.         break;
  960.   #if 0
  961. *** old-NetBSD/src/gnu/usr.bin/groff/include/ptable.h
  962. --- NetBSD/src/gnu/usr.bin/groff/include/ptable.h
  963. ***************
  964. *** 96,102 ****
  965.   {                                          \
  966.     assert(key != 0);                                  \
  967.     unsigned long h = hash_string(key);                          \
  968. !   for (unsigned n = unsigned(h % size);                          \
  969.          v[n].key != 0;                                  \
  970.          n = (n == 0 ? size - 1 : n - 1))                          \
  971.       if (strcmp(v[n].key, key) == 0) {                          \
  972. --- 96,103 ----
  973.   {                                          \
  974.     assert(key != 0);                                  \
  975.     unsigned long h = hash_string(key);                          \
  976. !   unsigned n;                                                                 \
  977. !   for (n = unsigned(h % size);                                  \
  978.          v[n].key != 0;                                  \
  979.          n = (n == 0 ? size - 1 : n - 1))                          \
  980.       if (strcmp(v[n].key, key) == 0) {                          \
  981. ***************
  982. *** 116,122 ****
  983.       if (oldv[i].val == 0)                              \
  984.         a_delete oldv[i].key;                              \
  985.       else {                                      \
  986. !       for (unsigned j = unsigned(hash_string(oldv[i].key) % size);          \
  987.              v[j].key != 0;                              \
  988.              j = (j == 0 ? size - 1 : j - 1))                      \
  989.            ;                                  \
  990. --- 117,124 ----
  991.       if (oldv[i].val == 0)                              \
  992.         a_delete oldv[i].key;                              \
  993.       else {                                      \
  994. !       unsigned j;                                      \
  995. !       for (j = unsigned(hash_string(oldv[i].key) % size);                  \
  996.              v[j].key != 0;                              \
  997.              j = (j == 0 ? size - 1 : j - 1))                      \
  998.            ;                                  \
  999. *** old-NetBSD/src/gnu/usr.bin/groff/indxbib/indxbib.cc
  1000. --- NetBSD/src/gnu/usr.bin/groff/indxbib/indxbib.cc
  1001. ***************
  1002. *** 242,248 ****
  1003.       string path;
  1004.       int lineno = 1;
  1005.       for (;;) {
  1006. !       for (int c = getc(fp); c != '\n' && c != EOF; c = getc(fp)) {
  1007.       if (c == '\0')
  1008.         error_with_file_and_line(foption, lineno,
  1009.                      "nul character in pathname ignored");
  1010. --- 242,249 ----
  1011.       string path;
  1012.       int lineno = 1;
  1013.       for (;;) {
  1014. !       int c;
  1015. !       for (c = getc(fp); c != '\n' && c != EOF; c = getc(fp)) {
  1016.       if (c == '\0')
  1017.         error_with_file_and_line(foption, lineno,
  1018.                      "nul character in pathname ignored");
  1019. *** old-NetBSD/src/gnu/usr.bin/groff/libbib/index.cc
  1020. --- NetBSD/src/gnu/usr.bin/groff/libbib/index.cc
  1021. ***************
  1022. *** 506,512 ****
  1023.       return first_list;
  1024.     if (*second_list < 0)
  1025.       return second_list;
  1026. !   for (const int *p = first_list; *p >= 0; p++)
  1027.       ;
  1028.     int len = p - first_list;
  1029.     for (p = second_list; *p >= 0; p++)
  1030. --- 506,513 ----
  1031.       return first_list;
  1032.     if (*second_list < 0)
  1033.       return second_list;
  1034. !   const int *p;
  1035. !   for (p = first_list; *p >= 0; p++)
  1036.       ;
  1037.     int len = p - first_list;
  1038.     for (p = second_list; *p >= 0; p++)
  1039. ***************
  1040. *** 586,592 ****
  1041.   void index_search_item::add_out_of_date_file(int fd, const char *filename,
  1042.                            int fid)
  1043.   {
  1044. !   for (search_item **pp = &out_of_date_files; *pp; pp = &(*pp)->next)
  1045.       if ((*pp)->is_named(filename))
  1046.         return;
  1047.     *pp = make_linear_search_item(fd, filename, fid);
  1048. --- 587,594 ----
  1049.   void index_search_item::add_out_of_date_file(int fd, const char *filename,
  1050.                            int fid)
  1051.   {
  1052. !   search_item **pp;
  1053. !   for (pp = &out_of_date_files; *pp; pp = &(*pp)->next)
  1054.       if ((*pp)->is_named(filename))
  1055.         return;
  1056.     *pp = make_linear_search_item(fd, filename, fid);
  1057. *** old-NetBSD/src/gnu/usr.bin/groff/libbib/linear.cc
  1058. --- NetBSD/src/gnu/usr.bin/groff/libbib/linear.cc
  1059. ***************
  1060. *** 58,64 ****
  1061.   
  1062.   map_init::map_init()
  1063.   {
  1064. !   for (int i = 0; i < 256; i++)
  1065.       map[i] = csalnum(i) ? cmlower(i) : '\0';
  1066.     for (i = 0; i < 256; i++) {
  1067.       if (cslower(i)) {
  1068. --- 58,65 ----
  1069.   
  1070.   map_init::map_init()
  1071.   {
  1072. !   int i;
  1073. !   for (i = 0; i < 256; i++)
  1074.       map[i] = csalnum(i) ? cmlower(i) : '\0';
  1075.     for (i = 0; i < 256; i++) {
  1076.       if (cslower(i)) {
  1077. ***************
  1078. *** 175,181 ****
  1079.       if (*p++ == '\n') {
  1080.         if (p == end || *p == '%')
  1081.       break;
  1082. !       for (const char *q = p; *q == ' ' || *q == '\t'; q++)
  1083.       ;
  1084.         if (*q == '\n')
  1085.       break;
  1086. --- 176,183 ----
  1087.       if (*p++ == '\n') {
  1088.         if (p == end || *p == '%')
  1089.       break;
  1090. !       const char *q;
  1091. !       for (q = p; *q == ' ' || *q == '\t'; q++)
  1092.       ;
  1093.         if (*q == '\n')
  1094.       break;
  1095. ***************
  1096. *** 190,196 ****
  1097.       if (*p++ == '\n') {
  1098.         if (p == bufend)
  1099.       break;
  1100. !       for (const char *q = p; *q == ' ' || *q == '\t'; q++)
  1101.       ;
  1102.         if (*q == '\n')
  1103.       break;
  1104. --- 192,199 ----
  1105.       if (*p++ == '\n') {
  1106.         if (p == bufend)
  1107.       break;
  1108. !       const char *q;
  1109. !       for (q = p; *q == ' ' || *q == '\t'; q++)
  1110.       ;
  1111.         if (*q == '\n')
  1112.       break;
  1113. ***************
  1114. *** 262,268 ****
  1115.         *start = p + 1;
  1116.       return 1;
  1117.         }
  1118. !       for (const char *q = p - 1; *q == ' ' || *q == '\t'; q--)
  1119.       ;
  1120.         if (*q == '\n') {
  1121.       if (start)
  1122. --- 265,272 ----
  1123.         *start = p + 1;
  1124.       return 1;
  1125.         }
  1126. !       const char *q;
  1127. !       for (q = p - 1; *q == ' ' || *q == '\t'; q--)
  1128.       ;
  1129.         if (*q == '\n') {
  1130.       if (start)
  1131. ***************
  1132. *** 392,398 ****
  1133.       if (!found)
  1134.         break;
  1135.       const char *refend = find_end(bufend, found + keys[0]->length());
  1136. !     for (int i = 1; i < nkeys; i++)
  1137.         if (!search_and_check(keys[i], refstart, refend))
  1138.       break;
  1139.       if (i >= nkeys) {
  1140. --- 396,403 ----
  1141.       if (!found)
  1142.         break;
  1143.       const char *refend = find_end(bufend, found + keys[0]->length());
  1144. !     int i;
  1145. !     for (i = 1; i < nkeys; i++)
  1146.         if (!search_and_check(keys[i], refstart, refend))
  1147.       break;
  1148.       if (i >= nkeys) {
  1149. *** old-NetBSD/src/gnu/usr.bin/groff/libbib/search.cc
  1150. --- NetBSD/src/gnu/usr.bin/groff/libbib/search.cc
  1151. ***************
  1152. *** 62,68 ****
  1153.         p = make_linear_search_item(fd, filename, next_fid);
  1154.     }
  1155.     if (p) {
  1156. !     for (search_item **pp = &list; *pp; pp = &(*pp)->next)
  1157.         ;
  1158.       *pp = p;
  1159.       next_fid = p->next_filename_id();
  1160. --- 62,69 ----
  1161.         p = make_linear_search_item(fd, filename, next_fid);
  1162.     }
  1163.     if (p) {
  1164. !     search_item **pp;
  1165. !     for (pp = &list; *pp; pp = &(*pp)->next)
  1166.         ;
  1167.       *pp = p;
  1168.       next_fid = p->next_filename_id();
  1169. *** old-NetBSD/src/gnu/usr.bin/groff/libdriver/input.cc
  1170. --- NetBSD/src/gnu/usr.bin/groff/libdriver/input.cc
  1171. ***************
  1172. *** 268,274 ****
  1173.       int n;
  1174.       int *p = 0;
  1175.       int szp = 0;
  1176. !     for (int np = 0; possibly_get_integer(&n); np++) {
  1177.         if (np >= szp) {
  1178.           if (szp == 0) {
  1179.             szp = 16;
  1180. --- 268,275 ----
  1181.       int n;
  1182.       int *p = 0;
  1183.       int szp = 0;
  1184. !     int np;
  1185. !     for (np = 0; possibly_get_integer(&n); np++) {
  1186.         if (np >= szp) {
  1187.           if (szp == 0) {
  1188.             szp = 16;
  1189. ***************
  1190. *** 290,296 ****
  1191.           env.hpos += p[0];
  1192.       }
  1193.       else { 
  1194. !       for (int i = 0; i < np/2; i++) {
  1195.           env.hpos += p[i*2];
  1196.           env.vpos += p[i*2 + 1];
  1197.         }
  1198. --- 291,298 ----
  1199.           env.hpos += p[0];
  1200.       }
  1201.       else { 
  1202. !       int i;
  1203. !       for (i = 0; i < np/2; i++) {
  1204.           env.hpos += p[i*2];
  1205.           env.vpos += p[i*2 + 1];
  1206.         }
  1207. *** old-NetBSD/src/gnu/usr.bin/groff/libdriver/printer.cc
  1208. --- NetBSD/src/gnu/usr.bin/groff/libdriver/printer.cc
  1209. ***************
  1210. *** 64,70 ****
  1211.         if (n >= nfonts)
  1212.       nfonts = n + 1;
  1213.         font_table = new font *[nfonts];
  1214. !       for (int i = 0; i < old_nfonts; i++)
  1215.       font_table[i] = old_font_table[i];
  1216.         for (i = old_nfonts; i < nfonts; i++)
  1217.       font_table[i] = 0;
  1218. --- 64,71 ----
  1219.         if (n >= nfonts)
  1220.       nfonts = n + 1;
  1221.         font_table = new font *[nfonts];
  1222. !       int i;
  1223. !       for (i = 0; i < old_nfonts; i++)
  1224.       font_table[i] = old_font_table[i];
  1225.         for (i = old_nfonts; i < nfonts; i++)
  1226.       font_table[i] = 0;
  1227. *** old-NetBSD/src/gnu/usr.bin/groff/libgroff/font.cc
  1228. --- NetBSD/src/gnu/usr.bin/groff/libgroff/font.cc
  1229. ***************
  1230. *** 246,252 ****
  1231.     if (!widths_cache)
  1232.       widths_cache = new font_widths_cache(point_size, ch_size);
  1233.     else if (widths_cache->point_size != point_size) {
  1234. !     for (font_widths_cache **p = &widths_cache; *p; p = &(*p)->next)
  1235.         if ((*p)->point_size == point_size)
  1236.       break;
  1237.       if (*p) {
  1238. --- 246,253 ----
  1239.     if (!widths_cache)
  1240.       widths_cache = new font_widths_cache(point_size, ch_size);
  1241.     else if (widths_cache->point_size != point_size) {
  1242. !     font_widths_cache **p;
  1243. !     for (p = &widths_cache; *p; p = &(*p)->next)
  1244.         if ((*p)->point_size == point_size)
  1245.       break;
  1246.       if (*p) {
  1247. ***************
  1248. *** 398,404 ****
  1249.   
  1250.   void font::compact()
  1251.   {
  1252. !   for (int i = nindices - 1; i >= 0; i--)
  1253.       if (ch_index[i] >= 0)
  1254.         break;
  1255.     i++;
  1256. --- 399,406 ----
  1257.   
  1258.   void font::compact()
  1259.   {
  1260. !   int i;
  1261. !   for (i = nindices - 1; i >= 0; i--)
  1262.       if (ch_index[i] >= 0)
  1263.         break;
  1264.     i++;
  1265. ***************
  1266. *** 728,734 ****
  1267.     while (t.next()) {
  1268.       char *p = strtok(t.buf, WS);
  1269.       int found = 0;
  1270. !     for (int i = 0; !found && i < sizeof(table)/sizeof(table[0]); i++)
  1271.         if (strcmp(table[i].command, p) == 0)
  1272.       found = 1;
  1273.       if (found) {
  1274. --- 730,737 ----
  1275.     while (t.next()) {
  1276.       char *p = strtok(t.buf, WS);
  1277.       int found = 0;
  1278. !     int i;
  1279. !     for (i = 0; !found && i < sizeof(table)/sizeof(table[0]); i++)
  1280.         if (strcmp(table[i].command, p) == 0)
  1281.       found = 1;
  1282.       if (found) {
  1283. ***************
  1284. *** 830,836 ****
  1285.       else if (strcmp("styles", p) == 0) {
  1286.         int style_table_size = 5;
  1287.         style_table = (const char **)new char *[style_table_size];
  1288. !       for (int j = 0; j < style_table_size; j++)
  1289.       style_table[j] = 0;
  1290.         int i = 0;
  1291.         for (;;) {
  1292. --- 833,840 ----
  1293.       else if (strcmp("styles", p) == 0) {
  1294.         int style_table_size = 5;
  1295.         style_table = (const char **)new char *[style_table_size];
  1296. !       int j;
  1297. !       for (j = 0; j < style_table_size; j++)
  1298.       style_table[j] = 0;
  1299.         int i = 0;
  1300.         for (;;) {
  1301. *** old-NetBSD/src/gnu/usr.bin/groff/libgroff/lf.cc
  1302. --- NetBSD/src/gnu/usr.bin/groff/libgroff/lf.cc
  1303. ***************
  1304. *** 45,51 ****
  1305.       change_lineno(ln);
  1306.       return 1;
  1307.     }
  1308. !   for (const char *q = p;
  1309.          *q != '\0' && *q != ' ' && *q != '\n' && *q != '\\';
  1310.          q++)
  1311.       ;
  1312. --- 45,52 ----
  1313.       change_lineno(ln);
  1314.       return 1;
  1315.     }
  1316. !   const char *q;
  1317. !   for (q = p;
  1318.          *q != '\0' && *q != ' ' && *q != '\n' && *q != '\\';
  1319.          q++)
  1320.       ;
  1321. *** old-NetBSD/src/gnu/usr.bin/groff/libgroff/nametoindex.cc
  1322. --- NetBSD/src/gnu/usr.bin/groff/libgroff/nametoindex.cc
  1323. ***************
  1324. *** 51,57 ****
  1325.   character_indexer::character_indexer()
  1326.   : next_index(0)
  1327.   {
  1328. !   for (int i = 0; i < 256; i++)
  1329.       ascii_index[i] = -1;
  1330.     for (i = 0; i < NSMALL; i++)
  1331.       small_number_index[i] = -1;
  1332. --- 51,58 ----
  1333.   character_indexer::character_indexer()
  1334.   : next_index(0)
  1335.   {
  1336. !   int i;
  1337. !   for (i = 0; i < 256; i++)
  1338.       ascii_index[i] = -1;
  1339.     for (i = 0; i < NSMALL; i++)
  1340.       small_number_index[i] = -1;
  1341. *** old-NetBSD/src/gnu/usr.bin/groff/libgroff/ptable.cc
  1342. --- NetBSD/src/gnu/usr.bin/groff/libgroff/ptable.cc
  1343. ***************
  1344. *** 44,50 ****
  1345.   
  1346.   unsigned next_ptable_size(unsigned n)
  1347.   {
  1348. !   for (const unsigned *p = table_sizes; *p <= n; p++)
  1349.       if (*p == 0)
  1350.         fatal("cannot expand table");
  1351.     return *p;
  1352. --- 44,51 ----
  1353.   
  1354.   unsigned next_ptable_size(unsigned n)
  1355.   {
  1356. !   const unsigned *p;
  1357. !   for (p = table_sizes; *p <= n; p++)
  1358.       if (*p == 0)
  1359.         fatal("cannot expand table");
  1360.     return *p;
  1361. *** old-NetBSD/src/gnu/usr.bin/groff/libgroff/string.cc
  1362. --- NetBSD/src/gnu/usr.bin/groff/libgroff/string.cc
  1363. ***************
  1364. *** 281,287 ****
  1365.     char *p = ptr;
  1366.     int n = len;
  1367.     int nnuls = 0;
  1368. !   for (int i = 0; i < n; i++)
  1369.       if (p[i] == '\0')
  1370.         nnuls++;
  1371.     char *q = new char[n + 1 - nnuls];
  1372. --- 281,288 ----
  1373.     char *p = ptr;
  1374.     int n = len;
  1375.     int nnuls = 0;
  1376. !   int i;
  1377. !   for (i = 0; i < n; i++)
  1378.       if (p[i] == '\0')
  1379.         nnuls++;
  1380.     char *q = new char[n + 1 - nnuls];
  1381. *** old-NetBSD/src/gnu/usr.bin/groff/lkbib/lkbib.cc
  1382. --- NetBSD/src/gnu/usr.bin/groff/lkbib/lkbib.cc
  1383. ***************
  1384. *** 96,102 ****
  1385.     if (list.nfiles() == 0)
  1386.       fatal("no databases");
  1387.     int total_len = 0;
  1388. !   for (int i = optind; i < argc; i++)
  1389.       total_len += strlen(argv[i]);
  1390.     total_len += argc - optind - 1 + 1; // for spaces and '\0'
  1391.     char *buffer = new char[total_len];
  1392. --- 96,103 ----
  1393.     if (list.nfiles() == 0)
  1394.       fatal("no databases");
  1395.     int total_len = 0;
  1396. !   int i;
  1397. !   for (i = optind; i < argc; i++)
  1398.       total_len += strlen(argv[i]);
  1399.     total_len += argc - optind - 1 + 1; // for spaces and '\0'
  1400.     char *buffer = new char[total_len];
  1401. ***************
  1402. *** 110,116 ****
  1403.     search_list_iterator iter(&list, buffer);
  1404.     const char *start;
  1405.     int len;
  1406. !   for (int count = 0; iter.next(&start, &len); count++) {
  1407.       if (fwrite(start, 1, len, stdout) != len)
  1408.         fatal("write error on stdout: %1", strerror(errno));
  1409.       // Can happen for last reference in file.
  1410. --- 111,118 ----
  1411.     search_list_iterator iter(&list, buffer);
  1412.     const char *start;
  1413.     int len;
  1414. !   int count;
  1415. !   for (count = 0; iter.next(&start, &len); count++) {
  1416.       if (fwrite(start, 1, len, stdout) != len)
  1417.         fatal("write error on stdout: %1", strerror(errno));
  1418.       // Can happen for last reference in file.
  1419. *** old-NetBSD/src/gnu/usr.bin/groff/lookbib/lookbib.cc
  1420. --- NetBSD/src/gnu/usr.bin/groff/lookbib/lookbib.cc
  1421. ***************
  1422. *** 106,112 ****
  1423.       search_list_iterator iter(&list, line);
  1424.       const char *start;
  1425.       int len;
  1426. !     for (int count = 0; iter.next(&start, &len); count++) {
  1427.         if (fwrite(start, 1, len, stdout) != len)
  1428.       fatal("write error on stdout: %1", strerror(errno));
  1429.         // Can happen for last reference in file.
  1430. --- 106,113 ----
  1431.       search_list_iterator iter(&list, line);
  1432.       const char *start;
  1433.       int len;
  1434. !     int count;
  1435. !     for (count = 0; iter.next(&start, &len); count++) {
  1436.         if (fwrite(start, 1, len, stdout) != len)
  1437.       fatal("write error on stdout: %1", strerror(errno));
  1438.         // Can happen for last reference in file.
  1439. *** old-NetBSD/src/gnu/usr.bin/groff/pic/lex.cc
  1440. --- NetBSD/src/gnu/usr.bin/groff/pic/lex.cc
  1441. ***************
  1442. *** 361,367 ****
  1443.   {
  1444.     char *argv[9];
  1445.     int argc = 0;
  1446. !   for (int i = 0; i < 9; i++)
  1447.       argv[i] = 0;
  1448.     int level = 0;
  1449.     int c;
  1450. --- 361,368 ----
  1451.   {
  1452.     char *argv[9];
  1453.     int argc = 0;
  1454. !   int i;
  1455. !   for (i = 0; i < 9; i++)
  1456.       argv[i] = 0;
  1457.     int level = 0;
  1458.     int c;
  1459. *** old-NetBSD/src/gnu/usr.bin/groff/pic/object.cc
  1460. --- NetBSD/src/gnu/usr.bin/groff/pic/object.cc
  1461. ***************
  1462. *** 512,518 ****
  1463.   
  1464.   void object_list::wrap_up_block(object_list *ol)
  1465.   {
  1466. !   for (object *p = tail; p && p->type() != MARK_OBJECT; p = p->prev)
  1467.       ;
  1468.     assert(p != 0);
  1469.     ol->head = p->next;
  1470. --- 512,519 ----
  1471.   
  1472.   void object_list::wrap_up_block(object_list *ol)
  1473.   {
  1474. !   object *p;
  1475. !   for (p = tail; p && p->type() != MARK_OBJECT; p = p->prev)
  1476.       ;
  1477.     assert(p != 0);
  1478.     ol->head = p->next;
  1479. ***************
  1480. *** 595,601 ****
  1481.   {
  1482.     aligned = a;
  1483.     int len = 0;
  1484. !   for (text_item *p = t; p; p = p->next)
  1485.       len++;
  1486.     if (len == 0)
  1487.       text = 0;
  1488. --- 596,603 ----
  1489.   {
  1490.     aligned = a;
  1491.     int len = 0;
  1492. !   text_item *p;
  1493. !   for (p = t; p; p = p->next)
  1494.       len++;
  1495.     if (len == 0)
  1496.       text = 0;
  1497. ***************
  1498. *** 1341,1347 ****
  1499.     // Absolutise all movements
  1500.     position endpos = startpos;
  1501.     int nsegments = 0;
  1502. !   for (segment *s = segment_list; s; s = s->next, nsegments++)
  1503.       if (s->is_absolute)
  1504.         endpos = s->pos;
  1505.       else {
  1506. --- 1343,1350 ----
  1507.     // Absolutise all movements
  1508.     position endpos = startpos;
  1509.     int nsegments = 0;
  1510. !   segment *s;
  1511. !   for (s = segment_list; s; s = s->next, nsegments++)
  1512.       if (s->is_absolute)
  1513.         endpos = s->pos;
  1514.       else {
  1515. ***************
  1516. *** 1767,1773 ****
  1517.   
  1518.   void path::append(char *s)
  1519.   {
  1520. !   for (string_list **p = &label_list; *p; p = &(*p)->next)
  1521.       ;
  1522.     *p = new string_list(s);
  1523.   }
  1524. --- 1770,1777 ----
  1525.   
  1526.   void path::append(char *s)
  1527.   {
  1528. !   string_list **p;
  1529. !   for (p = &label_list; *p; p = &(*p)->next)
  1530.       ;
  1531.     *p = new string_list(s);
  1532.   }
  1533. *** old-NetBSD/src/gnu/usr.bin/groff/pic/pic.y
  1534. --- NetBSD/src/gnu/usr.bin/groff/pic/pic.y
  1535. ***************
  1536. *** 940,946 ****
  1537.       | object_spec text   %prec TEXT
  1538.           {
  1539.             $$ = $1;
  1540. !           for (text_item **p = & $$->text; *p; p = &(*p)->next)
  1541.               ;
  1542.             *p = new text_item($2.str, $2.filename, $2.lineno);
  1543.           }
  1544. --- 940,947 ----
  1545.       | object_spec text   %prec TEXT
  1546.           {
  1547.             $$ = $1;
  1548. !           text_item **p;
  1549. !           for (p = & $$->text; *p; p = &(*p)->next)
  1550.               ;
  1551.             *p = new text_item($2.str, $2.filename, $2.lineno);
  1552.           }
  1553. ***************
  1554. *** 948,954 ****
  1555.           {
  1556.             $$ = $1;
  1557.             if ($$->text) {
  1558. !             for (text_item *p = $$->text; p->next; p = p->next)
  1559.                 ;
  1560.               p->adj.h = LEFT_ADJUST;
  1561.             }
  1562. --- 949,956 ----
  1563.           {
  1564.             $$ = $1;
  1565.             if ($$->text) {
  1566. !             text_item *p;
  1567. !             for (p = $$->text; p->next; p = p->next)
  1568.                 ;
  1569.               p->adj.h = LEFT_ADJUST;
  1570.             }
  1571. ***************
  1572. *** 957,963 ****
  1573.           {
  1574.             $$ = $1;
  1575.             if ($$->text) {
  1576. !             for (text_item *p = $$->text; p->next; p = p->next)
  1577.                 ;
  1578.               p->adj.h = RIGHT_ADJUST;
  1579.             }
  1580. --- 959,966 ----
  1581.           {
  1582.             $$ = $1;
  1583.             if ($$->text) {
  1584. !             text_item *p;
  1585. !             for (p = $$->text; p->next; p = p->next)
  1586.                 ;
  1587.               p->adj.h = RIGHT_ADJUST;
  1588.             }
  1589. ***************
  1590. *** 966,972 ****
  1591.           {
  1592.             $$ = $1;
  1593.             if ($$->text) {
  1594. !             for (text_item *p = $$->text; p->next; p = p->next)
  1595.                 ;
  1596.               p->adj.v = ABOVE_ADJUST;
  1597.             }
  1598. --- 969,976 ----
  1599.           {
  1600.             $$ = $1;
  1601.             if ($$->text) {
  1602. !             text_item *p;
  1603. !             for (p = $$->text; p->next; p = p->next)
  1604.                 ;
  1605.               p->adj.v = ABOVE_ADJUST;
  1606.             }
  1607. ***************
  1608. *** 975,980 ****
  1609. --- 979,985 ----
  1610.           {
  1611.             $$ = $1;
  1612.             if ($$->text) {
  1613. +             text_item *p;
  1614.               for (text_item *p = $$->text; p->next; p = p->next)
  1615.                 ;
  1616.               p->adj.v = BELOW_ADJUST;
  1617. ***************
  1618. *** 1162,1168 ****
  1619.       ordinal object_type
  1620.           {
  1621.             int count = 0;
  1622. !           for (object *p = olist.head; p != 0; p = p->next)
  1623.               if (p->type() == $2 && ++count == $1) {
  1624.                 $$ = p;
  1625.                 break;
  1626. --- 1167,1174 ----
  1627.       ordinal object_type
  1628.           {
  1629.             int count = 0;
  1630. !           object *p;
  1631. !           for (p = olist.head; p != 0; p = p->next)
  1632.               if (p->type() == $2 && ++count == $1) {
  1633.                 $$ = p;
  1634.                 break;
  1635. ***************
  1636. *** 1176,1182 ****
  1637.       | optional_ordinal_last object_type
  1638.           {
  1639.             int count = 0;
  1640. !           for (object *p = olist.tail; p != 0; p = p->prev)
  1641.               if (p->type() == $2 && ++count == $1) {
  1642.                 $$ = p;
  1643.                 break;
  1644. --- 1182,1189 ----
  1645.       | optional_ordinal_last object_type
  1646.           {
  1647.             int count = 0;
  1648. !           object *p;
  1649. !           for (p = olist.tail; p != 0; p = p->prev)
  1650.               if (p->type() == $2 && ++count == $1) {
  1651.                 $$ = p;
  1652.                 break;
  1653. *** old-NetBSD/src/gnu/usr.bin/groff/refer/label.y
  1654. --- NetBSD/src/gnu/usr.bin/groff/refer/label.y
  1655. ***************
  1656. *** 872,878 ****
  1657.     if (v[0]->get_number() != num + 1
  1658.         || v[1]->get_number() != num + 2)
  1659.       return 0;
  1660. !   for (int i = 2; i < n; i++)
  1661.       if (v[i]->get_number() != num + i + 1)
  1662.         break;
  1663.     result = get_label(type);
  1664. --- 872,879 ----
  1665.     if (v[0]->get_number() != num + 1
  1666.         || v[1]->get_number() != num + 2)
  1667.       return 0;
  1668. !   int i;
  1669. !   for (i = 2; i < n; i++)
  1670.       if (v[i]->get_number() != num + i + 1)
  1671.         break;
  1672.     result = get_label(type);
  1673. ***************
  1674. *** 945,951 ****
  1675.         label_table[i] = 0;
  1676.     }
  1677.     unsigned h = hash_string(label.contents(), label.length()) % label_table_size;
  1678. !   for (label_info **ptr = label_table + h;
  1679.          *ptr != 0;
  1680.          (ptr == label_table)
  1681.          ? (ptr = label_table + label_table_size - 1)
  1682. --- 946,953 ----
  1683.         label_table[i] = 0;
  1684.     }
  1685.     unsigned h = hash_string(label.contents(), label.length()) % label_table_size;
  1686. !   label_info **ptr;
  1687. !   for (ptr = label_table + h;
  1688.          *ptr != 0;
  1689.          (ptr == label_table)
  1690.          ? (ptr = label_table + label_table_size - 1)
  1691. ***************
  1692. *** 970,976 ****
  1693.         if (old_table[i]) {
  1694.       unsigned h = hash_string(label_pool.contents() + old_table[i]->start,
  1695.                    old_table[i]->length);
  1696. !     for (label_info **p = label_table + (h % label_table_size);
  1697.            *p != 0;
  1698.            (p == label_table)
  1699.            ? (p = label_table + label_table_size - 1)
  1700. --- 972,979 ----
  1701.         if (old_table[i]) {
  1702.       unsigned h = hash_string(label_pool.contents() + old_table[i]->start,
  1703.                    old_table[i]->length);
  1704. !     label_info **p;
  1705. !     for (p = label_table + (h % label_table_size);
  1706.            *p != 0;
  1707.            (p == label_table)
  1708.            ? (p = label_table + label_table_size - 1)
  1709. ***************
  1710. *** 1165,1171 ****
  1711.   {
  1712.     if (nauthors < 0) {
  1713.       const char *dummy;
  1714. !     for (int na = 0; get_author(na, &dummy) != 0; na++)
  1715.         ;
  1716.       ((reference *)this)->nauthors = na;
  1717.     }
  1718. --- 1168,1175 ----
  1719.   {
  1720.     if (nauthors < 0) {
  1721.       const char *dummy;
  1722. !     int na;
  1723. !     for (na = 0; get_author(na, &dummy) != 0; na++)
  1724.         ;
  1725.       ((reference *)this)->nauthors = na;
  1726.     }
  1727. *** old-NetBSD/src/gnu/usr.bin/groff/refer/ref.cc
  1728. --- NetBSD/src/gnu/usr.bin/groff/refer/ref.cc
  1729. ***************
  1730. *** 54,60 ****
  1731.   : no(-1), field(0), nfields(0), h(0), merged(0), label_ptr(0),
  1732.     computed_authors(0), last_needed_author(-1), nauthors(-1)
  1733.   {
  1734. !   for (int i = 0; i < 256; i++)
  1735.       field_index[i] = NULL_FIELD_INDEX;
  1736.     if (ridp)
  1737.       rid = *ridp;
  1738. --- 54,61 ----
  1739.   : no(-1), field(0), nfields(0), h(0), merged(0), label_ptr(0),
  1740.     computed_authors(0), last_needed_author(-1), nauthors(-1)
  1741.   {
  1742. !   int i;
  1743. !   for (i = 0; i < 256; i++)
  1744.       field_index[i] = NULL_FIELD_INDEX;
  1745.     if (ridp)
  1746.       rid = *ridp;
  1747. ***************
  1748. *** 199,205 ****
  1749.     string *old_field = field;
  1750.     field = new string[nfields + 1];
  1751.     int pos = 0;
  1752. !   for (int i = 0; i < int(c); i++)
  1753.       if (field_index[i] != NULL_FIELD_INDEX)
  1754.         pos++;
  1755.     for (i = 0; i < pos; i++)
  1756. --- 200,207 ----
  1757.     string *old_field = field;
  1758.     field = new string[nfields + 1];
  1759.     int pos = 0;
  1760. !   int i;
  1761. !   for (i = 0; i < int(c); i++)
  1762.       if (field_index[i] != NULL_FIELD_INDEX)
  1763.         pos++;
  1764.     for (i = 0; i < pos; i++)
  1765. ***************
  1766. *** 222,228 ****
  1767.       return;
  1768.     string *old_field = field;
  1769.     field = new string[nfields - 1];
  1770. !   for (int i = 0; i < int(field_index[c]); i++)
  1771.       field[i].move(old_field[i]);
  1772.     for (i = field_index[c]; i < nfields - 1; i++)
  1773.       field[i].move(old_field[i + 1]);
  1774. --- 224,231 ----
  1775.       return;
  1776.     string *old_field = field;
  1777.     field = new string[nfields - 1];
  1778. !   int i;
  1779. !   for (i = 0; i < int(field_index[c]); i++)
  1780.       field[i].move(old_field[i]);
  1781.     for (i = field_index[c]; i < nfields - 1; i++)
  1782.       field[i].move(old_field[i + 1]);
  1783. ***************
  1784. *** 330,336 ****
  1785.        a < ae;
  1786.        a = strchr(a, '\0') + 1)
  1787.         if (first_word_len == strlen(a)) {
  1788. !     for (int j = 0; j < first_word_len; j++)
  1789.         if (a[j] != cmlower(s[j]))
  1790.           break;
  1791.       if (j >= first_word_len) {
  1792. --- 333,340 ----
  1793.        a < ae;
  1794.        a = strchr(a, '\0') + 1)
  1795.         if (first_word_len == strlen(a)) {
  1796. !     int j;
  1797. !     for (j = 0; j < first_word_len; j++)
  1798.         if (a[j] != cmlower(s[j]))
  1799.           break;
  1800.       if (j >= first_word_len) {
  1801. ***************
  1802. *** 395,401 ****
  1803.   {
  1804.     const char *end = s + len;
  1805.     for (;;) {
  1806. !     for (const char *ptr = s;
  1807.        ptr < end && *ptr != SORT_SUB_SEP && *ptr != SORT_SUB_SUB_SEP;
  1808.        ptr++)
  1809.         ;
  1810. --- 399,406 ----
  1811.   {
  1812.     const char *end = s + len;
  1813.     for (;;) {
  1814. !     const char *ptr;
  1815. !     for (ptr = s;
  1816.        ptr < end && *ptr != SORT_SUB_SEP && *ptr != SORT_SUB_SUB_SEP;
  1817.        ptr++)
  1818.         ;
  1819. ***************
  1820. *** 692,698 ****
  1821.     const char *ptr = f.contents();
  1822.     int len = f.length();
  1823.     int nfield_seps = 0;
  1824. !   for (int j = 0; j < len; j++)
  1825.       if (ptr[j] == FIELD_SEPARATOR)
  1826.         nfield_seps++;
  1827.     if (nfield_seps == 0)
  1828. --- 697,704 ----
  1829.     const char *ptr = f.contents();
  1830.     int len = f.length();
  1831.     int nfield_seps = 0;
  1832. !   int j;
  1833. !   for (j = 0; j < len; j++)
  1834.       if (ptr[j] == FIELD_SEPARATOR)
  1835.         nfield_seps++;
  1836.     if (nfield_seps == 0)
  1837. *** old-NetBSD/src/gnu/usr.bin/groff/refer/refer.cc
  1838. --- NetBSD/src/gnu/usr.bin/groff/refer/refer.cc
  1839. ***************
  1840. *** 179,185 ****
  1841.           num = opt;
  1842.           opt = 0;
  1843.         }
  1844. !       for (const char *ptr = num; *ptr; ptr++)
  1845.           if (!csdigit(*ptr)) {
  1846.             error("bad character `%1' in argument to -f option", *ptr);
  1847.             break;
  1848. --- 179,186 ----
  1849.           num = opt;
  1850.           opt = 0;
  1851.         }
  1852. !       const char *ptr;
  1853. !       for (ptr = num; *ptr; ptr++)
  1854.           if (!csdigit(*ptr)) {
  1855.             error("bad character `%1' in argument to -f option", *ptr);
  1856.             break;
  1857. ***************
  1858. *** 227,233 ****
  1859.       break;
  1860.         case 'a':
  1861.       {
  1862. !       for (const char *ptr = ++opt; *ptr; ptr++)
  1863.           if (!csdigit(*ptr)) {
  1864.             error("argument to `a' option not a number");
  1865.             break;
  1866. --- 228,235 ----
  1867.       break;
  1868.         case 'a':
  1869.       {
  1870. !       const char *ptr;
  1871. !       for (ptr = ++opt; *ptr; ptr++)
  1872.           if (!csdigit(*ptr)) {
  1873.             error("argument to `a' option not a number");
  1874.             break;
  1875. ***************
  1876. *** 697,703 ****
  1877.     reference *ref = make_reference(str, &flags);
  1878.     ref->compute_hash_code();
  1879.     unsigned h = ref->hash();
  1880. !   for (reference **ptr = reference_hash_table + (h % hash_table_size);
  1881.          *ptr != 0;
  1882.          ((ptr == reference_hash_table)
  1883.       ? (ptr = reference_hash_table + hash_table_size - 1)
  1884. --- 699,706 ----
  1885.     reference *ref = make_reference(str, &flags);
  1886.     ref->compute_hash_code();
  1887.     unsigned h = ref->hash();
  1888. !   reference **ptr;
  1889. !   for (ptr = reference_hash_table + (h % hash_table_size);
  1890.          *ptr != 0;
  1891.          ((ptr == reference_hash_table)
  1892.       ? (ptr = reference_hash_table + hash_table_size - 1)
  1893. ***************
  1894. *** 727,733 ****
  1895.       reference_hash_table[i] = 0;
  1896.         for (i = 0; i < old_size; i++)
  1897.       if (old_table[i]) {
  1898. !       for (reference **p = (reference_hash_table
  1899.                   + (old_table[i]->hash() % hash_table_size));
  1900.              *p;
  1901.              ((p == reference_hash_table)
  1902. --- 730,737 ----
  1903.       reference_hash_table[i] = 0;
  1904.         for (i = 0; i < old_size; i++)
  1905.       if (old_table[i]) {
  1906. !       reference **p;
  1907. !       for (p = (reference_hash_table
  1908.                   + (old_table[i]->hash() % hash_table_size));
  1909.              *p;
  1910.              ((p == reference_hash_table)
  1911. ***************
  1912. *** 785,791 ****
  1913.       for (int i = 1; i < n; i++) {
  1914.         int num = v[i]->get_number();
  1915.         reference *temp = v[i];
  1916. !       for (int j = i - 1; j >= 0 && v[j]->get_number() > num; j--)
  1917.       v[j + 1] = v[j];
  1918.         v[j + 1] = temp;
  1919.       }
  1920. --- 789,796 ----
  1921.       for (int i = 1; i < n; i++) {
  1922.         int num = v[i]->get_number();
  1923.         reference *temp = v[i];
  1924. !       int j;
  1925. !       for (j = i - 1; j >= 0 && v[j]->get_number() > num; j--)
  1926.       v[j + 1] = v[j];
  1927.         v[j + 1] = temp;
  1928.       }
  1929. ***************
  1930. *** 1213,1219 ****
  1931.       16000057, 32000011, 64000031, 128000003, 0 
  1932.     };
  1933.   
  1934. !   for (const int *p = table_sizes; *p <= n && *p != 0; p++)
  1935.       ;
  1936.     assert(*p != 0);
  1937.     return *p;
  1938. --- 1218,1225 ----
  1939.       16000057, 32000011, 64000031, 128000003, 0 
  1940.     };
  1941.   
  1942. !   const int *p;
  1943. !   for (p = table_sizes; *p <= n && *p != 0; p++)
  1944.       ;
  1945.     assert(*p != 0);
  1946.     return *p;
  1947. *** old-NetBSD/src/gnu/usr.bin/groff/refer/token.cc
  1948. --- NetBSD/src/gnu/usr.bin/groff/refer/token.cc
  1949. ***************
  1950. *** 190,196 ****
  1951.   
  1952.   static void init_ascii()
  1953.   {
  1954. !   for (const char *p = "abcdefghijklmnopqrstuvwxyz"; *p; p++) {
  1955.       char buf[2];
  1956.       buf[0] = *p;
  1957.       buf[1] = '\0';
  1958. --- 190,197 ----
  1959.   
  1960.   static void init_ascii()
  1961.   {
  1962. !   const char *p;
  1963. !   for (p = "abcdefghijklmnopqrstuvwxyz"; *p; p++) {
  1964.       char buf[2];
  1965.       buf[0] = *p;
  1966.       buf[1] = '\0';
  1967. ***************
  1968. *** 296,302 ****
  1969.   
  1970.   static void init_special_chars()
  1971.   {
  1972. !   for (const char *p = "':^`~"; *p; p++)
  1973.       for (const char *q = "aeiouy"; *q; q++) {
  1974.         // Use a variable to work around bug in gcc 2.0
  1975.         char c = cmupper(*q);
  1976. --- 297,304 ----
  1977.   
  1978.   static void init_special_chars()
  1979.   {
  1980. !   const char *p;
  1981. !   for (p = "':^`~"; *p; p++)
  1982.       for (const char *q = "aeiouy"; *q; q++) {
  1983.         // Use a variable to work around bug in gcc 2.0
  1984.         char c = cmupper(*q);
  1985. *** old-NetBSD/src/gnu/usr.bin/groff/tbl/main.cc
  1986. --- NetBSD/src/gnu/usr.bin/groff/tbl/main.cc
  1987. ***************
  1988. *** 690,696 ****
  1989.   
  1990.   void input_entry_format::debug_print()
  1991.   {
  1992. !   for (int i = 0; i < pre_vline; i++)
  1993.       putc('|', stderr);
  1994.     entry_format::debug_print();
  1995.     if (!width.empty()) {
  1996. --- 690,697 ----
  1997.   
  1998.   void input_entry_format::debug_print()
  1999.   {
  2000. !   int i;
  2001. !   for (i = 0; i < pre_vline; i++)
  2002.       putc('|', stderr);
  2003.     entry_format::debug_print();
  2004.     if (!width.empty()) {
  2005. ***************
  2006. *** 1393,1399 ****
  2007.     }
  2008.     // Do this here rather than at the beginning in case continued formats
  2009.     // change it.
  2010. !   for (int i = 0; i < ncolumns - 1; i++)
  2011.       if (f->separation[i] >= 0)
  2012.         tbl->set_column_separation(i, f->separation[i]);
  2013.     for (i = 0; i < ncolumns; i++)
  2014. --- 1394,1401 ----
  2015.     }
  2016.     // Do this here rather than at the beginning in case continued formats
  2017.     // change it.
  2018. !   int i;
  2019. !   for (i = 0; i < ncolumns - 1; i++)
  2020.       if (f->separation[i] >= 0)
  2021.         tbl->set_column_separation(i, f->separation[i]);
  2022.     for (i = 0; i < ncolumns; i++)
  2023. *** old-NetBSD/src/gnu/usr.bin/groff/tbl/table.cc
  2024. --- NetBSD/src/gnu/usr.bin/groff/tbl/table.cc
  2025. ***************
  2026. *** 663,669 ****
  2027.     prints(".if \\n[" SAVED_FILL_REG "] .fi\n"
  2028.        ".in 0\n");
  2029.     prints(".ll ");
  2030. !   for (int i = start_col; i <= end_col; i++)
  2031.       if (mw[i].empty())
  2032.         break;
  2033.     if (i > end_col) {
  2034. --- 663,670 ----
  2035.     prints(".if \\n[" SAVED_FILL_REG "] .fi\n"
  2036.        ".in 0\n");
  2037.     prints(".ll ");
  2038. !   int i;
  2039. !   for (i = start_col; i <= end_col; i++)
  2040.       if (mw[i].empty())
  2041.         break;
  2042.     if (i > end_col) {
  2043. ***************
  2044. *** 1274,1280 ****
  2045.   
  2046.   void table::add_stuff(stuff *p)
  2047.   {
  2048. !   for (stuff **pp = &stuff_list; *pp; pp = &(*pp)->next)
  2049.       ;
  2050.     *pp = p;
  2051.   }
  2052. --- 1275,1282 ----
  2053.   
  2054.   void table::add_stuff(stuff *p)
  2055.   {
  2056. !   stuff **pp;
  2057. !   for (pp = &stuff_list; *pp; pp = &(*pp)->next)
  2058.       ;
  2059.     *pp = p;
  2060.   }
  2061. ***************
  2062. *** 1324,1330 ****
  2063.       assert(allocated_rows > r);
  2064.       while (nrows <= r) {
  2065.         entry[nrows] = new table_entry*[ncolumns];
  2066. !       for (int i = 0; i < ncolumns; i++)
  2067.       entry[nrows][i] = 0;
  2068.         vline[nrows] = new char[ncolumns+1];
  2069.         for (i = 0; i < ncolumns+1; i++)
  2070. --- 1326,1333 ----
  2071.       assert(allocated_rows > r);
  2072.       while (nrows <= r) {
  2073.         entry[nrows] = new table_entry*[ncolumns];
  2074. !       int i;
  2075. !       for (i = 0; i < ncolumns; i++)
  2076.       entry[nrows][i] = 0;
  2077.         vline[nrows] = new char[ncolumns+1];
  2078.         for (i = 0; i < ncolumns+1; i++)
  2079. ***************
  2080. *** 1590,1596 ****
  2081.         e->input_filename = fn;
  2082.         e->start_row = e->end_row = r;
  2083.         e->start_col = e->end_col = c;
  2084. !       for (table_entry **p = &entry_list; *p; p = &(*p)->next)
  2085.       ;
  2086.         *p = e;
  2087.         entry[r][c] = e;
  2088. --- 1593,1600 ----
  2089.         e->input_filename = fn;
  2090.         e->start_row = e->end_row = r;
  2091.         e->start_col = e->end_col = c;
  2092. !       table_entry **p;
  2093. !       for (p = &entry_list; *p; p = &(*p)->next)
  2094.       ;
  2095.         *p = e;
  2096.         entry[r][c] = e;
  2097. ***************
  2098. *** 1924,1930 ****
  2099.     printfs(".nr " NEEDED_REG " \\n[%1]-(\\n[%2]", 
  2100.         span_width_reg(start_col, end_col),
  2101.         span_width_reg(start_col, start_col));
  2102. !   for (int i = start_col + 1; i <= end_col; i++) {
  2103.       // The column separation may shrink with the expand option.
  2104.       if (!(flags & EXPAND))
  2105.         printfs("+%1n", as_string(column_separation[i - 1]));
  2106. --- 1928,1935 ----
  2107.     printfs(".nr " NEEDED_REG " \\n[%1]-(\\n[%2]", 
  2108.         span_width_reg(start_col, end_col),
  2109.         span_width_reg(start_col, start_col));
  2110. !   int i;
  2111. !   for (i = start_col + 1; i <= end_col; i++) {
  2112.       // The column separation may shrink with the expand option.
  2113.       if (!(flags & EXPAND))
  2114.         printfs("+%1n", as_string(column_separation[i - 1]));
  2115. ***************
  2116. *** 1975,1981 ****
  2117.     table_entry *p = entry_list;
  2118.     while (p) {
  2119.       if (p->end_col != p->start_col) {
  2120. !       for (horizontal_span *q = span_list; q; q = q->next)
  2121.       if (q->start_col == p->start_col
  2122.           && q->end_col == p->end_col)
  2123.         break;
  2124. --- 1980,1987 ----
  2125.     table_entry *p = entry_list;
  2126.     while (p) {
  2127.       if (p->end_col != p->start_col) {
  2128. !       horizontal_span *q;
  2129. !       for (q = span_list; q; q = q->next)
  2130.       if (q->start_col == p->start_col
  2131.           && q->end_col == p->end_col)
  2132.         break;
  2133. ***************
  2134. *** 1990,1996 ****
  2135.     horizontal_span *unsorted = span_list;
  2136.     span_list = 0;
  2137.     while (unsorted) {
  2138. !     for (horizontal_span **pp = &span_list; *pp; pp = &(*pp)->next)
  2139.         if (unsorted->end_col < (*pp)->end_col
  2140.         || (unsorted->end_col == (*pp)->end_col
  2141.             && (unsorted->start_col > (*pp)->start_col)))
  2142. --- 1996,2003 ----
  2143.     horizontal_span *unsorted = span_list;
  2144.     span_list = 0;
  2145.     while (unsorted) {
  2146. !     horizontal_span **pp;
  2147. !     for (pp = &span_list; *pp; pp = &(*pp)->next)
  2148.         if (unsorted->end_col < (*pp)->end_col
  2149.         || (unsorted->end_col == (*pp)->end_col
  2150.             && (unsorted->start_col > (*pp)->start_col)))
  2151. ***************
  2152. *** 2017,2022 ****
  2153. --- 2024,2030 ----
  2154.     }
  2155.     if (flags & EXPAND) {
  2156.       int total_sep = left_separation + right_separation;
  2157. +     int i;
  2158.       for (int i = 0; i < ncolumns - 1; i++)
  2159.         total_sep += column_separation[i];
  2160.       if (total_sep != 0) {
  2161. ***************
  2162. *** 2035,2041 ****
  2163.     printfs(".nr %1 %2*\\n[" SEPARATION_FACTOR_REG "]\n",
  2164.         column_start_reg(0),
  2165.         as_string(left_separation));
  2166. !   for (int i = 1;; i++) {
  2167.       printfs(".nr %1 \\n[%2]+\\n[%3]\n",
  2168.           column_end_reg(i-1),
  2169.           column_start_reg(i-1),
  2170. --- 2043,2050 ----
  2171.     printfs(".nr %1 %2*\\n[" SEPARATION_FACTOR_REG "]\n",
  2172.         column_start_reg(0),
  2173.         as_string(left_separation));
  2174. !   int i;
  2175. !   for (i = 1;; i++) {
  2176.       printfs(".nr %1 \\n[%2]+\\n[%3]\n",
  2177.           column_end_reg(i-1),
  2178.           column_start_reg(i-1),
  2179. ***************
  2180. *** 2066,2072 ****
  2181.   void table::make_columns_equal()
  2182.   {
  2183.     int first = -1;        // index of first equal column
  2184. !   for (int i = 0; i < ncolumns; i++)
  2185.       if (equal[i]) {
  2186.         if (first < 0) {
  2187.       printfs(".nr %1 \\n[%1]", span_width_reg(i, i));
  2188. --- 2075,2082 ----
  2189.   void table::make_columns_equal()
  2190.   {
  2191.     int first = -1;        // index of first equal column
  2192. !   int i;
  2193. !   for (i = 0; i < ncolumns; i++)
  2194.       if (equal[i]) {
  2195.         if (first < 0) {
  2196.       printfs(".nr %1 \\n[%1]", span_width_reg(i, i));
  2197. ***************
  2198. *** 2149,2155 ****
  2199.            && entry[r][start_col] != 0
  2200.            && entry[r][start_col]->start_row != r)
  2201.       start_col++;
  2202. !       for (int end_col = start_col;
  2203.          end_col < ncolumns
  2204.          && (entry[r][end_col] == 0
  2205.              || entry[r][end_col]->start_row == r);
  2206. --- 2159,2166 ----
  2207.            && entry[r][start_col] != 0
  2208.            && entry[r][start_col]->start_row != r)
  2209.       start_col++;
  2210. !       int end_col;
  2211. !       for (end_col = start_col;
  2212.          end_col < ncolumns
  2213.          && (entry[r][end_col] == 0
  2214.              || entry[r][end_col]->start_row == r);
  2215. ***************
  2216. *** 2197,2203 ****
  2217.            && entry[r][start_col] != 0
  2218.            && entry[r][start_col]->start_row != r)
  2219.       start_col++;
  2220. !       for (int end_col = start_col;
  2221.          end_col < ncolumns
  2222.          && (entry[r][end_col] == 0
  2223.              || entry[r][end_col]->start_row == r);
  2224. --- 2208,2215 ----
  2225.            && entry[r][start_col] != 0
  2226.            && entry[r][start_col]->start_row != r)
  2227.       start_col++;
  2228. !       int end_col;
  2229. !       for (end_col = start_col;
  2230.          end_col < ncolumns
  2231.          && (entry[r][end_col] == 0
  2232.              || entry[r][end_col]->start_row == r);
  2233. ***************
  2234. *** 2305,2311 ****
  2235.       result = "";
  2236.     }
  2237.     else {
  2238. !     for (stuff *p = stuff_list; p && p->row < end_row + 1; p = p->next)
  2239.         ;
  2240.       if (p && p->row == end_row + 1 && p->is_double_line()) {
  2241.         result = "-" DOUBLE_LINE_SEP;
  2242. --- 2317,2324 ----
  2243.       result = "";
  2244.     }
  2245.     else {
  2246. !     stuff *p;
  2247. !     for (p = stuff_list; p && p->row < end_row + 1; p = p->next)
  2248.         ;
  2249.       if (p && p->row == end_row + 1 && p->is_double_line()) {
  2250.         result = "-" DOUBLE_LINE_SEP;
  2251. ***************
  2252. *** 2399,2405 ****
  2253.         && (end_row == nrows - 1 
  2254.             || vline[end_row+1][col] != vline[end_row][col]
  2255.             || vline_spanned(end_row+1, col))) {
  2256. !     for (int start_row = end_row - 1;
  2257.            start_row >= 0
  2258.            && vline[start_row][col] == vline[end_row][col]
  2259.            && !vline_spanned(start_row, col);
  2260. --- 2412,2419 ----
  2261.         && (end_row == nrows - 1 
  2262.             || vline[end_row+1][col] != vline[end_row][col]
  2263.             || vline_spanned(end_row+1, col))) {
  2264. !     int start_row;
  2265. !     for (start_row = end_row - 1;
  2266.            start_row >= 0
  2267.            && vline[start_row][col] == vline[end_row][col]
  2268.            && !vline_spanned(start_row, col);
  2269. ***************
  2270. *** 2498,2504 ****
  2271.     if (!(flags & NOKEEP) && row_begins_section(r))
  2272.       prints("." KEEP_MACRO_NAME "\n");
  2273.     int had_line = 0;
  2274. !   for (stuff *p = stuff_list; p && p->row < r; p = p->next)
  2275.       ;
  2276.     for (stuff *p1 = p; p1 && p1->row == r; p1 = p1->next)
  2277.       if (!p1->printed && (p1->is_single_line() || p1->is_double_line())) {
  2278. --- 2512,2519 ----
  2279.     if (!(flags & NOKEEP) && row_begins_section(r))
  2280.       prints("." KEEP_MACRO_NAME "\n");
  2281.     int had_line = 0;
  2282. !   stuff *p;
  2283. !   for (p = stuff_list; p && p->row < r; p = p->next)
  2284.       ;
  2285.     for (stuff *p1 = p; p1 && p1->row == r; p1 = p1->next)
  2286.       if (!p1->printed && (p1->is_single_line() || p1->is_double_line())) {
  2287. *** old-NetBSD/src/gnu/usr.bin/groff/tfmtodit/tfmtodit.cc
  2288. --- NetBSD/src/gnu/usr.bin/groff/tfmtodit/tfmtodit.cc
  2289. ***************
  2290. *** 825,831 ****
  2291.         m[4] = g.get_left_adjustment(i);
  2292.         m[5] = g.get_right_adjustment(i);
  2293.         printf("%s\t%d", p->ch, m[0]*MULTIPLIER);
  2294. !       for (int j = int(sizeof(m)/sizeof(m[0])) - 1; j > 0; j--)
  2295.       if (m[j] != 0)
  2296.         break;
  2297.         for (int k = 1; k <= j; k++)
  2298. --- 825,832 ----
  2299.         m[4] = g.get_left_adjustment(i);
  2300.         m[5] = g.get_right_adjustment(i);
  2301.         printf("%s\t%d", p->ch, m[0]*MULTIPLIER);
  2302. !       int j;
  2303. !       for (j = int(sizeof(m)/sizeof(m[0])) - 1; j > 0; j--)
  2304.       if (m[j] != 0)
  2305.         break;
  2306.         for (int k = 1; k <= j; k++)
  2307. *** old-NetBSD/src/gnu/usr.bin/groff/troff/dictionary.cc
  2308. --- NetBSD/src/gnu/usr.bin/groff/troff/dictionary.cc
  2309. ***************
  2310. *** 28,34 ****
  2311.   static int is_good_size(int p)
  2312.   {
  2313.     const int SMALL = 10;
  2314. !   for (unsigned i = 2; i <= p/2; i++)
  2315.       if (p % i == 0)
  2316.         return 0;
  2317.     for (i = 0x100; i != 0; i <<= 8)
  2318. --- 28,35 ----
  2319.   static int is_good_size(int p)
  2320.   {
  2321.     const int SMALL = 10;
  2322. !   unsigned i;
  2323. !   for (i = 2; i <= p/2; i++)
  2324.       if (p % i == 0)
  2325.         return 0;
  2326.     for (i = 0x100; i != 0; i <<= 8)
  2327. ***************
  2328. *** 49,55 ****
  2329.   
  2330.   void *dictionary::lookup(symbol s, void *v)
  2331.   {
  2332. !   for (int i = int(s.hash() % size); 
  2333.          table[i].v != 0;
  2334.          i == 0 ? i = size - 1: --i)
  2335.       if (s == table[i].s) {
  2336. --- 50,57 ----
  2337.   
  2338.   void *dictionary::lookup(symbol s, void *v)
  2339.   {
  2340. !   int i;
  2341. !   for (i = int(s.hash() % size); 
  2342.          table[i].v != 0;
  2343.          i == 0 ? i = size - 1: --i)
  2344.       if (s == table[i].s) {
  2345. ***************
  2346. *** 96,102 ****
  2347.   void *dictionary::remove(symbol s)
  2348.   {
  2349.     // this relies on the fact that we are using linear probing
  2350. !   for (int i = int(s.hash() % size);
  2351.          table[i].v != 0 && s != table[i].s;
  2352.          i == 0 ? i = size - 1: --i)
  2353.       ;
  2354. --- 98,105 ----
  2355.   void *dictionary::remove(symbol s)
  2356.   {
  2357.     // this relies on the fact that we are using linear probing
  2358. !   int i;
  2359. !   for (i = int(s.hash() % size);
  2360.          table[i].v != 0 && s != table[i].s;
  2361.          i == 0 ? i = size - 1: --i)
  2362.       ;
  2363. *** old-NetBSD/src/gnu/usr.bin/groff/troff/div.cc
  2364. --- NetBSD/src/gnu/usr.bin/groff/troff/div.cc
  2365. ***************
  2366. *** 446,452 ****
  2367.   void top_level_diversion::add_trap(symbol nm, vunits pos)
  2368.   {
  2369.     trap *first_free_slot = 0;
  2370. !   for (trap **p = &page_trap_list; *p; p = &(*p)->next) {
  2371.       if ((*p)->nm.is_null()) {
  2372.         if (first_free_slot == 0)
  2373.       first_free_slot = *p;
  2374. --- 446,453 ----
  2375.   void top_level_diversion::add_trap(symbol nm, vunits pos)
  2376.   {
  2377.     trap *first_free_slot = 0;
  2378. !   trap **p;
  2379. !   for (p = &page_trap_list; *p; p = &(*p)->next) {
  2380.       if ((*p)->nm.is_null()) {
  2381.         if (first_free_slot == 0)
  2382.       first_free_slot = *p;
  2383. *** old-NetBSD/src/gnu/usr.bin/groff/troff/div.h
  2384. --- NetBSD/src/gnu/usr.bin/groff/troff/div.h
  2385. ***************
  2386. *** 145,148 ****
  2387.   void handle_first_page_transition();
  2388.   void blank_line();
  2389.   
  2390. ! extern void cleanup_and_exit(int);
  2391. --- 145,154 ----
  2392.   void handle_first_page_transition();
  2393.   void blank_line();
  2394.   
  2395. ! #ifdef __GNUG__
  2396. ! #define NO_RETURN volatile
  2397. ! #else
  2398. ! #define NO_RETURN
  2399. ! #endif
  2400. ! extern NO_RETURN void cleanup_and_exit(int);
  2401. *** old-NetBSD/src/gnu/usr.bin/groff/troff/env.cc
  2402. --- NetBSD/src/gnu/usr.bin/groff/troff/env.cc
  2403. ***************
  2404. *** 136,142 ****
  2405.         )
  2406.       curdiv->output(nd, no_fill, vs, ls, width);
  2407.     else {
  2408. !     for (pending_output_line **p = &pending_lines; *p; p = &(*p)->next)
  2409.         ;
  2410.       *p = new pending_output_line(nd, no_fill, vs, ls, width);
  2411.     }
  2412. --- 136,143 ----
  2413.         )
  2414.       curdiv->output(nd, no_fill, vs, ls, width);
  2415.     else {
  2416. !     pending_output_line **p;
  2417. !     for (p = &pending_lines; *p; p = &(*p)->next)
  2418.         ;
  2419.       *p = new pending_output_line(nd, no_fill, vs, ls, width);
  2420.     }
  2421. ***************
  2422. *** 1586,1592 ****
  2423.     if (line == 0)
  2424.       return;
  2425.     hyphenation_type prev_type = line->get_hyphenation_type();
  2426. !   for (node **startp = &line->next; *startp != 0; startp = &(*startp)->next) {
  2427.       hyphenation_type this_type = (*startp)->get_hyphenation_type();
  2428.       if (prev_type == HYPHEN_BOUNDARY && this_type == HYPHEN_MIDDLE)
  2429.         break;
  2430. --- 1587,1594 ----
  2431.     if (line == 0)
  2432.       return;
  2433.     hyphenation_type prev_type = line->get_hyphenation_type();
  2434. !   node **startp;
  2435. !   for (startp = &line->next; *startp != 0; startp = &(*startp)->next) {
  2436.       hyphenation_type this_type = (*startp)->get_hyphenation_type();
  2437.       if (prev_type == HYPHEN_BOUNDARY && this_type == HYPHEN_MIDDLE)
  2438.         break;
  2439. ***************
  2440. *** 1705,1711 ****
  2441.       space_total = 0;
  2442.       width_total = 0;
  2443.       node *first_non_discardable = 0;
  2444. !     for (node *tem = line; tem != 0; tem = tem->next)
  2445.         if (!tem->discardable())
  2446.       first_non_discardable = tem;
  2447.       node *to_be_discarded;
  2448. --- 1707,1714 ----
  2449.       space_total = 0;
  2450.       width_total = 0;
  2451.       node *first_non_discardable = 0;
  2452. !     node *tem;
  2453. !     for (tem = line; tem != 0; tem = tem->next)
  2454.         if (!tem->discardable())
  2455.       first_non_discardable = tem;
  2456.       node *to_be_discarded;
  2457. ***************
  2458. *** 2025,2031 ****
  2459.   tab_type tab_stops::distance_to_next_tab(hunits curpos, hunits *distance)
  2460.   {
  2461.     hunits lastpos = 0;
  2462. !   for (tab *tem = initial_list; tem && tem->pos <= curpos; tem = tem->next)
  2463.       lastpos = tem->pos;
  2464.     if (tem) {
  2465.       *distance = tem->pos - curpos;
  2466. --- 2028,2035 ----
  2467.   tab_type tab_stops::distance_to_next_tab(hunits curpos, hunits *distance)
  2468.   {
  2469.     hunits lastpos = 0;
  2470. !   tab *tem;
  2471. !   for (tem = initial_list; tem && tem->pos <= curpos; tem = tem->next)
  2472.       lastpos = tem->pos;
  2473.     if (tem) {
  2474.       *distance = tem->pos - curpos;
  2475. ***************
  2476. *** 2053,2059 ****
  2477.     static int buf_size = 0;
  2478.     // figure out a maximum on the amount of space we can need
  2479.     int count = 0;
  2480. !   for (tab *p = initial_list; p; p = p->next)
  2481.       ++count;
  2482.     for (p = repeated_list; p; p = p->next)
  2483.       ++count;
  2484. --- 2057,2064 ----
  2485.     static int buf_size = 0;
  2486.     // figure out a maximum on the amount of space we can need
  2487.     int count = 0;
  2488. !   tab *p;
  2489. !   for (p = initial_list; p; p = p->next)
  2490.       ++count;
  2491.     for (p = repeated_list; p; p = p->next)
  2492.       ++count;
  2493. ***************
  2494. *** 2149,2155 ****
  2495.   
  2496.   void tab_stops::add_tab(hunits pos, tab_type type, int repeated)
  2497.   {
  2498. !   for (tab **p = repeated ? &repeated_list : &initial_list; *p; p = &(*p)->next)
  2499.       ;
  2500.     *p = new tab(pos, type);
  2501.   }
  2502. --- 2154,2161 ----
  2503.   
  2504.   void tab_stops::add_tab(hunits pos, tab_type type, int repeated)
  2505.   {
  2506. !   tab **p;
  2507. !   for (p = repeated ? &repeated_list : &initial_list; *p; p = &(*p)->next)
  2508.       ;
  2509.     *p = new tab(pos, type);
  2510.   }
  2511. ***************
  2512. *** 2282,2288 ****
  2513.       field_spaces += tab_field_spaces;
  2514.     }
  2515.     if (tab_contents != 0) {
  2516. !     for (node *tem = tab_contents; tem->next != 0; tem = tem->next)
  2517.         ;
  2518.       tem->next = line;
  2519.       line = tab_contents;
  2520. --- 2288,2295 ----
  2521.       field_spaces += tab_field_spaces;
  2522.     }
  2523.     if (tab_contents != 0) {
  2524. !     node *tem;
  2525. !     for (tem = tab_contents; tem->next != 0; tem = tem->next)
  2526.         ;
  2527.       tem->next = line;
  2528.       line = tab_contents;
  2529. ***************
  2530. *** 2390,2396 ****
  2531.           current_tab = TAB_NONE;
  2532.         }
  2533.         if (tab_contents != 0) {
  2534. !         for (node *tem = tab_contents; tem->next != 0; tem = tem->next)
  2535.             ;
  2536.           tem->next = line;
  2537.           line = tab_contents;
  2538. --- 2397,2404 ----
  2539.           current_tab = TAB_NONE;
  2540.         }
  2541.         if (tab_contents != 0) {
  2542. !         node *tem;
  2543. !         for (tem = tab_contents; tem->next != 0; tem = tem->next)
  2544.             ;
  2545.           tem->next = line;
  2546.           line = tab_contents;
  2547. ***************
  2548. *** 2901,2907 ****
  2549.   
  2550.   void hyphen_trie::hyphenate(const char *word, int len, int *hyphens)
  2551.   {
  2552. !   for (int j = 0; j < len+1; j++)
  2553.       hyphens[j] = 0;
  2554.     for (j = 0; j < len - 1; j++) {
  2555.       h = hyphens + j;
  2556. --- 2909,2916 ----
  2557.   
  2558.   void hyphen_trie::hyphenate(const char *word, int len, int *hyphens)
  2559.   {
  2560. !   int j;
  2561. !   for (j = 0; j < len+1; j++)
  2562.       hyphens[j] = 0;
  2563.     for (j = 0; j < len - 1; j++) {
  2564.       h = hyphens + j;
  2565. ***************
  2566. *** 2986,2992 ****
  2567.     int len = 0;
  2568.     char hbuf[WORD_MAX+2];
  2569.     char *buf = hbuf + 1;
  2570. !   for (hyphen_list *tem = h; tem && len < WORD_MAX; tem = tem->next) {
  2571.       if (tem->hyphenation_code != 0)
  2572.         buf[len++] = tem->hyphenation_code;
  2573.       else
  2574. --- 2995,3002 ----
  2575.     int len = 0;
  2576.     char hbuf[WORD_MAX+2];
  2577.     char *buf = hbuf + 1;
  2578. !   hyphen_list *tem;
  2579. !   for (tem = h; tem && len < WORD_MAX; tem = tem->next) {
  2580.       if (tem->hyphenation_code != 0)
  2581.         buf[len++] = tem->hyphenation_code;
  2582.       else
  2583. *** old-NetBSD/src/gnu/usr.bin/groff/troff/input.cc
  2584. --- NetBSD/src/gnu/usr.bin/groff/troff/input.cc
  2585. ***************
  2586. *** 513,519 ****
  2587.   
  2588.   void input_stack::next_file(FILE *fp, const char *s)
  2589.   {
  2590. !   for (input_iterator **pp = ⊤ *pp != &nil_iterator; pp = &(*pp)->next)
  2591.       if ((*pp)->next_file(fp, s))
  2592.         return;
  2593.     if (++level > limit && limit > 0)
  2594. --- 513,520 ----
  2595.   
  2596.   void input_stack::next_file(FILE *fp, const char *s)
  2597.   {
  2598. !   input_iterator **pp;
  2599. !   for (pp = ⊤ *pp != &nil_iterator; pp = &(*pp)->next)
  2600.       if ((*pp)->next_file(fp, s))
  2601.         return;
  2602.     if (++level > limit && limit > 0)
  2603. ***************
  2604. *** 1400,1406 ****
  2605.         symbol s = read_escape_name();
  2606.         if (s.is_null())
  2607.           break;
  2608. !       for (const char *p = s.contents(); *p != '\0'; p++)
  2609.           if (!csdigit(*p))
  2610.             break;
  2611.         if (*p)
  2612. --- 1401,1408 ----
  2613.         symbol s = read_escape_name();
  2614.         if (s.is_null())
  2615.           break;
  2616. !       const char *p;
  2617. !       for (p = s.contents(); *p != '\0'; p++)
  2618.           if (!csdigit(*p))
  2619.             break;
  2620.         if (*p)
  2621. ***************
  2622. *** 2730,2736 ****
  2623.   
  2624.   void macro_iterator::add_arg(const macro &m)
  2625.   {
  2626. !   for (arg_list **p = &args; *p; p = &((*p)->next))
  2627.       ;
  2628.     *p = new arg_list(m);
  2629.     ++argc;
  2630. --- 2732,2739 ----
  2631.   
  2632.   void macro_iterator::add_arg(const macro &m)
  2633.   {
  2634. !   arg_list **p;
  2635. !   for (p = &args; *p; p = &((*p)->next))
  2636.       ;
  2637.     *p = new arg_list(m);
  2638.     ++argc;
  2639. ***************
  2640. *** 3107,3113 ****
  2641.       }
  2642.     }
  2643.     else {
  2644. !     for (const char *p = s; *p && csdigit(*p); p++)
  2645.         ;
  2646.       if (*p)
  2647.         error("bad argument name `%1'", s);
  2648. --- 3110,3117 ----
  2649.       }
  2650.     }
  2651.     else {
  2652. !     const char *p;
  2653. !     for (p = s; *p && csdigit(*p); p++)
  2654.         ;
  2655.       if (*p)
  2656.         error("bad argument name `%1'", s);
  2657. ***************
  2658. *** 3245,3251 ****
  2659.         const char *s = term.contents();
  2660.         int d;
  2661.         // see if it matches term
  2662. !       for (int i = 0; s[i] != 0; i++) {
  2663.       d = get_copy(&n);
  2664.       if ((unsigned char)s[i] != d)
  2665.         break;
  2666. --- 3249,3256 ----
  2667.         const char *s = term.contents();
  2668.         int d;
  2669.         // see if it matches term
  2670. !       int i;
  2671. !       for (i = 0; s[i] != 0; i++) {
  2672.       d = get_copy(&n);
  2673.       if ((unsigned char)s[i] != d)
  2674.         break;
  2675. *** old-NetBSD/src/gnu/usr.bin/groff/troff/node.cc
  2676. --- NetBSD/src/gnu/usr.bin/groff/troff/node.cc
  2677. ***************
  2678. *** 610,616 ****
  2679.     next = tfont_list;
  2680.     tfont_list = this;
  2681.     tfont_spec plain_spec = plain();
  2682. !   for (tfont *p = tfont_list; p; p = p->next)
  2683.       if (*p == plain_spec) {
  2684.         plain_version = p;
  2685.         break;
  2686. --- 610,617 ----
  2687.     next = tfont_list;
  2688.     tfont_list = this;
  2689.     tfont_spec plain_spec = plain();
  2690. !   tfont *p;
  2691. !   for (p = tfont_list; p; p = p->next)
  2692.       if (*p == plain_spec) {
  2693.         plain_version = p;
  2694.         break;
  2695. ***************
  2696. *** 2374,2380 ****
  2697.     hunits w = n->width();
  2698.     if (w > max_width)
  2699.       max_width = w;
  2700. !   for (node **p = &list; *p; p = &(*p)->next)
  2701.       ;
  2702.     n->next = 0;
  2703.     *p = n;
  2704. --- 2375,2382 ----
  2705.     hunits w = n->width();
  2706.     if (w > max_width)
  2707.       max_width = w;
  2708. !   node **p;
  2709. !   for (p = &list; *p; p = &(*p)->next)
  2710.       ;
  2711.     n->next = 0;
  2712.     *p = n;
  2713. ***************
  2714. *** 2968,2974 ****
  2715.       if (pre == 0)
  2716.         *prep = next;
  2717.       else {
  2718. !       for (node *tem = pre; tem->next != 0; tem = tem->next)
  2719.       ;
  2720.         tem->next = next;
  2721.         *prep = pre;
  2722. --- 2970,2977 ----
  2723.       if (pre == 0)
  2724.         *prep = next;
  2725.       else {
  2726. !       node *tem;
  2727. !       for (tem = pre; tem->next != 0; tem = tem->next)
  2728.       ;
  2729.         tem->next = next;
  2730.         *prep = pre;
  2731. ***************
  2732. *** 3519,3525 ****
  2733.     if (list == 0)
  2734.       return;
  2735.     int npieces = 0;
  2736. !   for (node *tem = list; tem; tem = tem->next)
  2737.       ++npieces;
  2738.     vunits h = list->size();
  2739.     vunits totalh = h*npieces;
  2740. --- 3522,3529 ----
  2741.     if (list == 0)
  2742.       return;
  2743.     int npieces = 0;
  2744. !   node *tem;
  2745. !   for (tem = list; tem; tem = tem->next)
  2746.       ++npieces;
  2747.     vunits h = list->size();
  2748.     vunits totalh = h*npieces;
  2749. ***************
  2750. *** 4552,4558 ****
  2751.   
  2752.   int next_available_font_position()
  2753.   {
  2754. !   for (int i = 1; i < font_table_size && font_table[i] != 0; i++)
  2755.       ;
  2756.     return i;
  2757.   }
  2758. --- 4556,4563 ----
  2759.   
  2760.   int next_available_font_position()
  2761.   {
  2762. !   int i;
  2763. !   for (i = 1; i < font_table_size && font_table[i] != 0; i++)
  2764.       ;
  2765.     return i;
  2766.   }
  2767. *** old-NetBSD/src/gnu/usr.bin/groff/troff/symbol.cc
  2768. --- NetBSD/src/gnu/usr.bin/groff/troff/symbol.cc
  2769. ***************
  2770. *** 82,88 ****
  2771.       table_used = 0;
  2772.     }
  2773.     unsigned int hc = hash_string(p);
  2774. !   for (const char **pp  = table + hc % table_size; 
  2775.          *pp != 0; 
  2776.          (pp == table ? pp = table + table_size - 1 : --pp))
  2777.       if (strcmp(p, *pp) == 0) {
  2778. --- 82,89 ----
  2779.       table_used = 0;
  2780.     }
  2781.     unsigned int hc = hash_string(p);
  2782. !   const char **pp;
  2783. !   for (pp  = table + hc % table_size; 
  2784.          *pp != 0; 
  2785.          (pp == table ? pp = table + table_size - 1 : --pp))
  2786.       if (strcmp(p, *pp) == 0) {
  2787. ***************
  2788. *** 96,102 ****
  2789.     if (table_used  >= table_size - 1 || table_used >= table_size*FULL_MAX) {
  2790.       const char **old_table = table;
  2791.       unsigned int old_table_size = table_size;
  2792. !     for (int i = 1; table_sizes[i] <= old_table_size; i++)
  2793.         if (table_sizes[i] == 0)
  2794.       fatal("too many symbols");
  2795.       table_size = table_sizes[i];
  2796. --- 97,104 ----
  2797.     if (table_used  >= table_size - 1 || table_used >= table_size*FULL_MAX) {
  2798.       const char **old_table = table;
  2799.       unsigned int old_table_size = table_size;
  2800. !     int i;
  2801. !     for (i = 1; table_sizes[i] <= old_table_size; i++)
  2802.         if (table_sizes[i] == 0)
  2803.       fatal("too many symbols");
  2804.       table_size = table_sizes[i];
  2805. *** old-NetBSD/src/gnu/usr.bin/rcs/rcsdiff/rcsdiff.c
  2806. --- NetBSD/src/gnu/usr.bin/rcs/rcsdiff/rcsdiff.c
  2807. ***************
  2808. *** 208,215 ****
  2809.               /* fall into */
  2810.           case 'C': case 'F': case 'I': case 'L': case 'W':
  2811.   #if DIFF_L
  2812. !             if (c == 'L'  &&  ++file_labels == 2)
  2813.               faterror("too many -L options");
  2814.   #endif
  2815.               *dcp++ = c;
  2816.               if (*a)
  2817. --- 208,216 ----
  2818.               /* fall into */
  2819.           case 'C': case 'F': case 'I': case 'L': case 'W':
  2820.   #if DIFF_L
  2821. !             if (c == 'L'  &&  file_labels++ == 2)
  2822.               faterror("too many -L options");
  2823. +             /* fall into */
  2824.   #endif
  2825.               *dcp++ = c;
  2826.               if (*a)
  2827. *** old-NetBSD/src/share/mk/bsd.prog.mk
  2828. --- NetBSD/src/share/mk/bsd.prog.mk
  2829. ***************
  2830. *** 20,25 ****
  2831. --- 20,26 ----
  2832.   LIBDES?=    ${DESTDIR}/usr/lib/libdes.a
  2833.   LIBEDIT?=    ${DESTDIR}/usr/lib/libedit.a
  2834.   LIBGCC?=    ${DESTDIR}/usr/lib/libgcc.a
  2835. + LIBGNUMALLOC?=    ${DESTDIR}/usr/lib/libgnumalloc.a
  2836.   LIBL?=        ${DESTDIR}/usr/lib/libl.a
  2837.   LIBKDB?=    ${DESTDIR}/usr/lib/libkdb.a
  2838.   LIBKRB?=    ${DESTDIR}/usr/lib/libkrb.a
  2839. ***************
  2840. *** 66,77 ****
  2841.   .if defined(DESTDIR)
  2842.   
  2843.   ${PROG}: ${LIBCRT0} ${OBJS} ${LIBC} ${DPADD}
  2844. !     ${CC} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} -nostdlib -L${DESTDIR}/usr/lib ${LIBCRT0} ${OBJS} ${LDADD} -lgcc -lc -lgcc
  2845.   
  2846.   .else
  2847.   
  2848.   ${PROG}: ${LIBCRT0} ${OBJS} ${LIBC} ${DPADD}
  2849. !     ${CC} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${OBJS} ${LDADD}
  2850.   
  2851.   .endif    # defined(DESTDIR)
  2852.   .endif    # defined(OBJS) && !empty(OBJS)
  2853. --- 67,78 ----
  2854.   .if defined(DESTDIR)
  2855.   
  2856.   ${PROG}: ${LIBCRT0} ${OBJS} ${LIBC} ${DPADD}
  2857. !     ${LINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} -nostdlib -L${DESTDIR}/usr/lib ${LIBCRT0} ${OBJS} ${LDADD} -lgcc -lc -lgcc
  2858.   
  2859.   .else
  2860.   
  2861.   ${PROG}: ${LIBCRT0} ${OBJS} ${LIBC} ${DPADD}
  2862. !     ${LINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${OBJS} ${LDADD}
  2863.   
  2864.   .endif    # defined(DESTDIR)
  2865.   .endif    # defined(OBJS) && !empty(OBJS)
  2866. *** old-NetBSD/src/share/mk/sys.mk
  2867. --- NetBSD/src/share/mk/sys.mk
  2868. ***************
  2869. *** 50,55 ****
  2870. --- 50,57 ----
  2871.   LD=        ld
  2872.   LDFLAGS=
  2873.   
  2874. + LINK=        $(CC)
  2875.   LINT=        lint
  2876.   LINTFLAGS=    -chapbx
  2877.   
  2878. *** old-NetBSD/src/sys/arch/amiga/Makefile
  2879. --- NetBSD/src/sys/arch/amiga/Makefile
  2880. ***************
  2881. *** 3,13 ****
  2882.   #    @(#)Makefile    7.3 (Berkeley) 6/9/91
  2883.   
  2884.   S=${BSDSRCDIR}/sys
  2885. ! COMM=    $S/vm/*.[ch] $S/ufs/*.[ch] $S/sys/*.h $S/compat/sunos/*.[ch] \
  2886.       $S/nfs/*.[ch] $S/netns/*.[ch] $S/netiso/*.[ch] \
  2887.       $S/netiso/xebec/*.[ch] $S/netinet/*.[ch] $S/netccitt/*.[ch] \
  2888.       $S/net/*.[ch] $S/miscfs/*/*.[ch] $S/kern/*.[ch] $S/dev/*.[ch] \
  2889. !     $S/scsi/*.[ch] $S/lib/libkern/m68k/*.[ch] $S/lib/libkern/*.[ch]
  2890.   
  2891.   # Makefile for amiga tags file
  2892.   
  2893. --- 3,14 ----
  2894.   #    @(#)Makefile    7.3 (Berkeley) 6/9/91
  2895.   
  2896.   S=${BSDSRCDIR}/sys
  2897. ! COMM=    $S/vm/*.[ch] $S/ufs/*/*.[ch] $S/sys/*.h $S/compat/sunos/*.[ch] \
  2898.       $S/nfs/*.[ch] $S/netns/*.[ch] $S/netiso/*.[ch] \
  2899.       $S/netiso/xebec/*.[ch] $S/netinet/*.[ch] $S/netccitt/*.[ch] \
  2900.       $S/net/*.[ch] $S/miscfs/*/*.[ch] $S/kern/*.[ch] $S/dev/*.[ch] \
  2901. !     $S/dev/isa/*.[ch] \
  2902. !     $S/scsi/*.[ch] $S/lib/libkern/arch/m68k/*.[ch] $S/lib/libkern/*.[ch]
  2903.   
  2904.   # Makefile for amiga tags file
  2905.   
  2906. ***************
  2907. *** 17,33 ****
  2908.   TAMIGA=    $S/arch/amiga/tags
  2909.   SAMIGA=    $S/arch/m68k/m68k/*.c $S/arch/m68k/include/*.h \
  2910.       $S/arch/amiga/amiga/*.[ch] $S/arch/amiga/include/*.h \
  2911. !     $S/arch/amiga/dev/*.[ch]
  2912.   AAMIGA=    $S/arch/m68k/m68k/*.s $S/arch/amiga/amiga/*.s
  2913.   
  2914.   # Directories in which to place amiga tags links
  2915. ! DAMIGA=    amiga dev include
  2916.   
  2917.   TAGS:
  2918.       -etags -dt ${COMM} ${SAMIGA} ${AAMIGA}
  2919. !     egrep "^ENTRY(.*)|^ALTENTRY(.*)" ${AAMIGA} | \
  2920. !         sed "s;\([^:]*\):\([^(]*\)(\([^, )]*\)\(.*\);\3 \1 /^\2(\3\4$$/;" \
  2921. !         >> ${TAMIGA}/tags
  2922.   
  2923.   tags:
  2924.       -ctags -dtf ${TAMIGA} ${COMM} ${SAMIGA}
  2925. --- 18,34 ----
  2926.   TAMIGA=    $S/arch/amiga/tags
  2927.   SAMIGA=    $S/arch/m68k/m68k/*.c $S/arch/m68k/include/*.h \
  2928.       $S/arch/amiga/amiga/*.[ch] $S/arch/amiga/include/*.h \
  2929. !     $S/arch/amiga/dev/*.[ch] $S/arch/amiga/isa/*.[ch]
  2930.   AAMIGA=    $S/arch/m68k/m68k/*.s $S/arch/amiga/amiga/*.s
  2931.   
  2932.   # Directories in which to place amiga tags links
  2933. ! DAMIGA=    amiga dev include isa
  2934.   
  2935.   TAGS:
  2936.       -etags -dt ${COMM} ${SAMIGA} ${AAMIGA}
  2937. ! #    egrep "^ENTRY(.*)|^ALTENTRY(.*)" ${AAMIGA} | \
  2938. ! #        sed "s;\([^:]*\):\([^(]*\)(\([^, )]*\)\(.*\);\3 \1 /^\2(\3\4$$/;" \
  2939. ! #        >> ${TAMIGA}/tags
  2940.   
  2941.   tags:
  2942.       -ctags -dtf ${TAMIGA} ${COMM} ${SAMIGA}
  2943. *** old-NetBSD/src/sys/arch/amiga/amiga/amiga_init.c
  2944. --- NetBSD/src/sys/arch/amiga/amiga/amiga_init.c
  2945. ***************
  2946. *** 79,89 ****
  2947.    */
  2948.   vm_offset_t INTREQRaddr;
  2949.   vm_offset_t INTREQWaddr;
  2950. ! /*
  2951. !  * these are used by the extended spl?() macros.
  2952. !  */
  2953. ! volatile unsigned short *amiga_intena_read, *amiga_intena_write;
  2954.   
  2955.   /*
  2956.    * the number of pages in our hw mapping and the start address
  2957. --- 79,86 ----
  2958.    */
  2959.   vm_offset_t INTREQRaddr;
  2960.   vm_offset_t INTREQWaddr;
  2961. ! vm_offset_t INTENARaddr;
  2962. ! vm_offset_t INTENAWaddr;
  2963.   
  2964.   /*
  2965.    * the number of pages in our hw mapping and the start address
  2966. ***************
  2967. *** 99,104 ****
  2968. --- 96,103 ----
  2969.   
  2970.   static u_long boot_flags;
  2971.   
  2972. + void    rollcolor __P((int));
  2973.   void *
  2974.   chipmem_steal(amount)
  2975.       long amount;
  2976. ***************
  2977. *** 172,177 ****
  2978. --- 171,180 ----
  2979.       u_int tc, end_loaded, ncd, i;
  2980.       u_int *sg, *pg, *pg2;
  2981.   
  2982. + #ifdef BOOT_DEBUG
  2983. +     rollcolor(0x008);
  2984. + #endif
  2985.       boot_fphystart = fphystart;
  2986.       boot_fphysize = fphysize;
  2987.       boot_cphysize = cphysize;
  2988. ***************
  2989. *** 232,237 ****
  2990. --- 235,244 ----
  2991.           }
  2992.       }
  2993.   
  2994. + #ifdef BOOT_DEBUG
  2995. +     rollcolor(0x080);
  2996. + #endif
  2997.       /*
  2998.        * Scan ConfigDev list and get size of Zorro I/O boards that are
  2999.        * outside the Zorro II I/O area.
  3000. ***************
  3001. *** 470,476 ****
  3002.       }
  3003.   
  3004.       /*
  3005. !      *[ following page tables MAY be allocated to ZORRO3 space,
  3006.        * but they're then later mapped in autoconf.c ]
  3007.        */
  3008.   
  3009. --- 477,483 ----
  3010.       }
  3011.   
  3012.       /*
  3013. !      *[ following page tables MAY be allocated to ZORRO2 or ZORRO3 space,
  3014.        * but they're then later mapped in autoconf.c ]
  3015.        */
  3016.   
  3017. ***************
  3018. *** 492,497 ****
  3019. --- 499,508 ----
  3020.       lowram  = fphystart >> PGSHIFT;
  3021.       physmem = fphysize >> PGSHIFT;
  3022.   
  3023. + #ifdef BOOT_DEBUG
  3024. +     rollcolor(0x800);
  3025. + #endif
  3026.       /*
  3027.        * get the pmap module in sync with reality.
  3028.        */
  3029. ***************
  3030. *** 582,587 ****
  3031. --- 593,600 ----
  3032.       CUSTOMbase = CUSTOMADDR;
  3033.       INTREQRaddr = (vm_offset_t)&custom.intreqr;
  3034.       INTREQWaddr = (vm_offset_t)&custom.intreq;
  3035. +     INTENARaddr = (vm_offset_t)&custom.intenar;
  3036. +     INTENAWaddr = (vm_offset_t)&custom.intena;
  3037.   
  3038.       /*
  3039.        * Get our chip memory allocation system working
  3040. ***************
  3041. *** 597,604 ****
  3042.       i = *(int *)proc0paddr;
  3043.       *(volatile int *)proc0paddr = i;
  3044.   
  3045.       /*
  3046. !      * disable all interupts but enable allow them to be enabled 
  3047.        * by specific driver code (global int enable bit)
  3048.        */
  3049.       custom.intena = 0x7fff;                /* disable ints */
  3050. --- 610,621 ----
  3051.       i = *(int *)proc0paddr;
  3052.       *(volatile int *)proc0paddr = i;
  3053.   
  3054. + #ifdef BOOT_DEBUG
  3055. +     rollcolor(0x088);
  3056. + #endif
  3057.       /*
  3058. !      * disable all interupts but allow them to be enabled 
  3059.        * by specific driver code (global int enable bit)
  3060.        */
  3061.       custom.intena = 0x7fff;                /* disable ints */
  3062. ***************
  3063. *** 608,620 ****
  3064.       ciab.icr = 0x7f;            /* and again */
  3065.   
  3066.       /*
  3067. -      * remember address of read and write intena register for use
  3068. -      * by extended spl?() macros.
  3069. -      */
  3070. -     amiga_intena_read  = &custom.intenar;
  3071. -     amiga_intena_write = &custom.intena;
  3072. -     /*
  3073.        * This is needed for 3000's with superkick ROM's. Bit 7 of
  3074.        * 0xde0002 enables the ROM if set. If this isn't set the machine
  3075.        * has to be powercycled in order for it to boot again. ICKA! RFH 
  3076. --- 625,630 ----
  3077. ***************
  3078. *** 637,643 ****
  3079.   {
  3080.       int s, i;
  3081.   
  3082. !     s = splhigh();
  3083.       /*
  3084.        * need to adjust count -
  3085.        * too slow when cache off, too fast when cache on
  3086. --- 647,653 ----
  3087.   {
  3088.       int s, i;
  3089.   
  3090. !     s = spl7();
  3091.       /*
  3092.        * need to adjust count -
  3093.        * too slow when cache off, too fast when cache on
  3094. *** old-NetBSD/src/sys/arch/amiga/amiga/cc.c
  3095. --- NetBSD/src/sys/arch/amiga/amiga/cc.c
  3096. ***************
  3097. *** 323,334 ****
  3098.    */
  3099.   
  3100.   struct audio_channel {
  3101. !     u_short  play_count;
  3102.   };
  3103.   
  3104.   /* - channel[4] */
  3105.   /* the data for each audio channel and what to do with it. */
  3106. ! static struct audio_channel channel[4];
  3107.   
  3108.   /* audio vbl node for vbl function  */
  3109.   struct vbl_node audio_vbl_node;    
  3110. --- 323,335 ----
  3111.    */
  3112.   
  3113.   struct audio_channel {
  3114. !     u_short  play_count;        /* number of times to loop sample */
  3115. !     handler_func_t handler;        /* interupt handler for channel */
  3116.   };
  3117.   
  3118.   /* - channel[4] */
  3119.   /* the data for each audio channel and what to do with it. */
  3120. ! struct audio_channel channel[4];
  3121.   
  3122.   /* audio vbl node for vbl function  */
  3123.   struct vbl_node audio_vbl_node;    
  3124. ***************
  3125. *** 337,342 ****
  3126. --- 338,344 ----
  3127.   cc_init_audio()
  3128.   {
  3129.       int i;
  3130. +     extern int defchannel_handler();
  3131.   
  3132.       /*
  3133.        * disable all audio interupts
  3134. ***************
  3135. *** 346,353 ****
  3136.       /*
  3137.        * initialize audio channels to off.
  3138.        */
  3139. !     for (i=0; i < 4; i++)
  3140.           channel[i].play_count = 0;
  3141.   }
  3142.   
  3143.   
  3144. --- 348,357 ----
  3145.       /*
  3146.        * initialize audio channels to off.
  3147.        */
  3148. !     for (i=0; i < 4; i++) {
  3149.           channel[i].play_count = 0;
  3150. +         channel[i].handler = defchannel_handler;
  3151. +     }
  3152.   }
  3153.   
  3154.   
  3155. ***************
  3156. *** 393,414 ****
  3157.           if ((ir & (flag << 7)) == 0)
  3158.               continue;
  3159.   
  3160. !         if (channel[i].play_count)
  3161. !             channel[i].play_count--;
  3162. !         else {
  3163. !             /*
  3164. !              * disable DMA to this channel and
  3165. !              * disable interrupts to this channel
  3166. !              */
  3167. !             custom.dmacon = flag;
  3168. !             custom.intena = (flag << 7);
  3169. !         }
  3170.           /*
  3171.            * clear this channels interrupt.
  3172.            */
  3173.           custom.intreq = (flag << 7);
  3174.       }
  3175.   out:
  3176.       /*
  3177.        * enable audio interupts with dma still set.
  3178. --- 397,410 ----
  3179.           if ((ir & (flag << 7)) == 0)
  3180.               continue;
  3181.   
  3182. !         if (channel[i].handler)
  3183. !             channel[i].handler(i);
  3184.           /*
  3185.            * clear this channels interrupt.
  3186.            */
  3187.           custom.intreq = (flag << 7);
  3188.       }
  3189.   out:
  3190.       /*
  3191.        * enable audio interupts with dma still set.
  3192. ***************
  3193. *** 418,423 ****
  3194. --- 414,439 ----
  3195.       custom.intena = INTF_SETCLR | (audio_dma << 7);
  3196.   }
  3197.   
  3198. + /*
  3199. +  * this is the channel handler used by the system
  3200. +  * other software modules are free to install their own
  3201. +  * handler
  3202. +  */
  3203. + defchannel_handler(i)
  3204. +     int i;
  3205. + {
  3206. +     if (channel[i].play_count)
  3207. +         channel[i].play_count--;
  3208. +     else {
  3209. +         /*
  3210. +          * disable DMA to this channel and
  3211. +          * disable interrupts to this channel
  3212. +          */
  3213. +         custom.dmacon = (1 << i);
  3214. +         custom.intena = (1 << (i + 7));
  3215. +     }
  3216. + }
  3217.   void
  3218.   play_sample(len, data, period, volume, channels, count)
  3219.       u_short len, *data, period, volume, channels;
  3220. ***************
  3221. *** 430,442 ****
  3222.   
  3223.       /* load the channels */
  3224.       for (ch = 0; ch < 4; ch++) {
  3225. !         if ((dmabits & (ch << ch)) == 0)
  3226.               continue;
  3227. !         custom.aud[ch].len = len;
  3228. !         custom.aud[ch].lc = data;
  3229.           custom.aud[ch].per = period;
  3230.           custom.aud[ch].vol = volume;
  3231. !         channel[ch].play_count = count;
  3232.       }
  3233.       /*
  3234.        * turn on interrupts and enable dma for channels and
  3235. --- 446,461 ----
  3236.   
  3237.       /* load the channels */
  3238.       for (ch = 0; ch < 4; ch++) {
  3239. !         if ((dmabits & (1 << ch)) == 0)
  3240.               continue;
  3241. !         /* busy */
  3242. !         if (channel[ch].handler != defchannel_handler)
  3243. !             continue;
  3244. !         channel[ch].play_count = count;
  3245.           custom.aud[ch].per = period;
  3246.           custom.aud[ch].vol = volume;
  3247. !         custom.aud[ch].len = len;
  3248. !         custom.aud[ch].lc = data;
  3249.       }
  3250.       /*
  3251.        * turn on interrupts and enable dma for channels and
  3252. *** old-NetBSD/src/sys/arch/amiga/amiga/cc.h
  3253. --- NetBSD/src/sys/arch/amiga/amiga/cc.h
  3254. ***************
  3255. *** 147,152 ****
  3256. --- 147,154 ----
  3257.   #define CHIPMEMTOP    (0x00200000)
  3258.   #define NCHIPMEMPG    btoc(CHIPMEMTOP - CHIPMEMBASE)
  3259.   
  3260. + typedef int (*handler_func_t)();
  3261.   /*
  3262.    * Prototypes.
  3263.    */
  3264. *** old-NetBSD/src/sys/arch/amiga/amiga/conf.c
  3265. --- NetBSD/src/sys/arch/amiga/amiga/conf.c
  3266. ***************
  3267. *** 94,99 ****
  3268. --- 94,109 ----
  3269.   };
  3270.   int    nblkdev = sizeof(bdevsw) / sizeof(bdevsw[0]);
  3271.   
  3272. + #if 0
  3273. + /* ioctl */
  3274. + #define    cdev_aconf_init(c,n) { \
  3275. +     (dev_type_open((*))) nullop, (dev_type_close((*))) nullop, \
  3276. +     (dev_type_read((*))) nullop, (dev_type_write((*))) nullop, \
  3277. +     dev_init(c,aconf,ioctl), (dev_type_stop((*))) enodev, 0, seltrue, \
  3278. +         (dev_type_map((*))) enodev, 0 \
  3279. + }
  3280. + #endif
  3281.   /* open, close, ioctl, select, mmap -- XXX should be a map device */
  3282.   #define    cdev_grf_init(c,n) { \
  3283.       dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) nullop, \
  3284. ***************
  3285. *** 114,119 ****
  3286. --- 124,135 ----
  3287.       dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
  3288.       0, (dev_type_select((*))) enodev, (dev_type_mmap((*))) enodev }
  3289.   
  3290. + /* open, close, write, ioctl */
  3291. + #define    cdev_lpt_init(c,n) { \
  3292. +     dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \
  3293. +     dev_init(c,n,write), dev_init(c,n,ioctl), (dev_type_stop((*))) enodev, \
  3294. +     0, seltrue, (dev_type_mmap((*))) enodev }
  3295.   cdev_decl(cn);
  3296.   cdev_decl(ctty);
  3297.   #define    mmread    mmrw
  3298. ***************
  3299. *** 128,133 ****
  3300. --- 144,153 ----
  3301.   #define    ptcioctl    ptyioctl
  3302.   cdev_decl(ptc);
  3303.   cdev_decl(log);
  3304. + #if 0
  3305. + #include "aconf.h"
  3306. + cdev_decl(aconf);
  3307. + #endif
  3308.   cdev_decl(sd);
  3309.   cdev_decl(cd);
  3310.   #include "grf.h"
  3311. ***************
  3312. *** 156,161 ****
  3313. --- 176,184 ----
  3314.   #include "bpfilter.h"
  3315.   cdev_decl(bpf);
  3316.   #include "tun.h"
  3317. + #if 0
  3318. + #define tunioctl tuncioctl /* XXX could be needed.  Markus had it...  */
  3319. + #endif
  3320.   cdev_decl(tun);
  3321.   #ifdef LKM
  3322.   #define NLKM 1
  3323. ***************
  3324. *** 163,168 ****
  3325. --- 186,195 ----
  3326.   #define NLKM 0
  3327.   #endif
  3328.   cdev_decl(lkm);
  3329. + #include "com.h"
  3330. + cdev_decl(com);
  3331. + #include "lpt.h"
  3332. + cdev_decl(lpt);
  3333.   
  3334.   struct cdevsw    cdevsw[] =
  3335.   {
  3336. ***************
  3337. *** 173,179 ****
  3338.       cdev_tty_init(NPTY,pts),    /* 4: pseudo-tty slave */
  3339.       cdev_ptc_init(NPTY,ptc),    /* 5: pseudo-tty master */
  3340.       cdev_log_init(1,log),        /* 6: /dev/klog */
  3341. -     cdev_disk_init(NCCD,ccd),    /* 7: concatenated disk driver */
  3342.       cdev_disk_init(NSD,sd),        /* 8: SCSI disk */
  3343.       cdev_disk_init(NCD,cd),        /* 9: SCSI CD-ROM */
  3344.       cdev_grf_init(NGRF,grf),    /* 10: frame buffer */
  3345. --- 200,205 ----
  3346. ***************
  3347. *** 199,204 ****
  3348. --- 225,233 ----
  3349.       cdev_lkm_dummy(),        /* 28 */
  3350.       cdev_lkm_dummy(),        /* 29 */
  3351.       cdev_lkm_dummy(),        /* 30 */
  3352. +     cdev_tty_init(NCOM,com),    /* 31: ISA serial port */
  3353. +     cdev_lpt_init(NLPT,lpt),    /* 32: parallel printer */
  3354. +     cdev_aconf_init(NACONF,aconf),  /* 33: /dev/autoconfig */
  3355.   };
  3356.   int    nchrdev = sizeof(cdevsw) / sizeof(cdevsw[0]);
  3357.   
  3358. ***************
  3359. *** 291,296 ****
  3360. --- 320,327 ----
  3361.       /* 28 */    NODEV,
  3362.       /* 29 */    NODEV,
  3363.       /* 30 */    NODEV,
  3364. +     /* 31 */    NODEV,
  3365. +     /* 32 */    NODEV,
  3366.   };
  3367.   
  3368.   /*
  3369. ***************
  3370. *** 317,322 ****
  3371. --- 348,354 ----
  3372.    */
  3373.   cons_decl(ser);
  3374.   cons_decl(ite);
  3375. + cons_decl(com);
  3376.   
  3377.   struct    consdev constab[] = {
  3378.   #if NSER > 0
  3379. ***************
  3380. *** 324,329 ****
  3381. --- 356,366 ----
  3382.   #endif
  3383.   #if NITE > 0
  3384.       cons_init(ite),
  3385. + #endif
  3386. + #if 0
  3387. + #if NCOM > 0
  3388. +     cons_init(com),
  3389. + #endif
  3390.   #endif
  3391.       { 0 },
  3392.   };
  3393. *** /dev/null
  3394. --- NetBSD/src/sys/arch/amiga/amiga/db_memrw.c
  3395. ***************
  3396. *** 0 ****
  3397. --- 1,161 ----
  3398. + /*    $NetBSD: db_memrw.c,v 1.4 1994/11/28 19:33:08 gwr Exp $    */
  3399. + /*
  3400. +  * Copyright (c) 1994 Gordon W. Ross
  3401. +  * All rights reserved.
  3402. +  *
  3403. +  * Redistribution and use in source and binary forms, with or without
  3404. +  * modification, are permitted provided that the following conditions
  3405. +  * are met:
  3406. +  * 1. Redistributions of source code must retain the above copyright
  3407. +  *    notice, this list of conditions and the following disclaimer.
  3408. +  * 2. Redistributions in binary form must reproduce the above copyright
  3409. +  *    notice, this list of conditions and the following disclaimer in the
  3410. +  *    documentation and/or other materials provided with the distribution.
  3411. +  * 3. The name of the author may not be used to endorse or promote products
  3412. +  *    derived from this software without specific prior written permission.
  3413. +  *
  3414. +  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  3415. +  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  3416. +  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  3417. +  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  3418. +  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  3419. +  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  3420. +  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  3421. +  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  3422. +  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  3423. +  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  3424. +  */
  3425. + /*
  3426. +  * Interface to the debugger for virtual memory read/write.
  3427. +  * To write in the text segment, we have to first make
  3428. +  * the page writable, do the write, then restore the PTE.
  3429. +  * For reads, validate address first to avoid MMU trap.
  3430. +  */
  3431. + #include <sys/param.h>
  3432. + #include <sys/proc.h>
  3433. + #include <vm/vm.h>
  3434. + #include <machine/db_machdep.h>
  3435. + #include <machine/pte.h>
  3436. + /*
  3437. +  * Read one byte somewhere in the kernel.
  3438. +  * It does not matter if this is slow. -gwr
  3439. +  */
  3440. + static char
  3441. + db_read_data(src)
  3442. +     char *src;
  3443. + {
  3444. +     u_int *pte;
  3445. +     vm_offset_t pgva;
  3446. +     int ch;
  3447. +     pgva = amiga_trunc_page((long)src);
  3448. +     pte = kvtopte(pgva);
  3449. +     if ((*pte & PG_V) == 0) {
  3450. +         db_printf(" address 0x%x not a valid page\n", src);
  3451. +         return 0;
  3452. +     }
  3453. +     return (*src);
  3454. + }
  3455. + /*
  3456. +  * Read bytes from kernel address space for debugger.
  3457. +  * It does not matter if this is slow. -gwr
  3458. +  */
  3459. + void
  3460. + db_read_bytes(addr, size, data)
  3461. +     vm_offset_t    addr;
  3462. +     register int    size;
  3463. +     register char    *data;
  3464. + {
  3465. +     char    *src, *limit;
  3466. +     src = (char *)addr;
  3467. +     limit = src + size;
  3468. +     while (src < limit) {
  3469. +         *data = db_read_data(src);
  3470. +         data++;
  3471. +         src++;
  3472. +     }
  3473. + }
  3474. + /*
  3475. +  * Write one byte somewhere in kernel text.
  3476. +  * It does not matter if this is slow. -gwr
  3477. +  */
  3478. + static void
  3479. + db_write_text(dst, ch)
  3480. +     char *dst;
  3481. +     int ch;
  3482. + {
  3483. +     u_int *pte, oldpte;
  3484. +     vm_offset_t pgva;
  3485. +     pgva = amiga_trunc_page((long)dst);
  3486. +     pte = kvtopte(pgva);
  3487. +     oldpte = *pte;
  3488. +     if ((oldpte & PG_V) == 0) {
  3489. +         db_printf(" address 0x%x not a valid page\n", dst);
  3490. +         return;
  3491. +     }
  3492. +     *pte = oldpte & ~PG_RO;
  3493. +     *dst = (char) ch;
  3494. +     *pte = oldpte;
  3495. + }
  3496. + /*
  3497. +  * Write one byte somewhere outside kernel text.
  3498. +  * It does not matter if this is slow. -gwr
  3499. +  */
  3500. + static void
  3501. + db_write_data(dst, ch)
  3502. +     char *dst;
  3503. +     int ch;
  3504. + {
  3505. +     u_int *pte;
  3506. +     vm_offset_t pgva;
  3507. +     pgva = amiga_trunc_page((long)dst);
  3508. +     pte = kvtopte(pgva);
  3509. +     if ((*pte & (PG_V | PG_RO)) != PG_V) {
  3510. +         db_printf(" address 0x%x not a valid page\n", dst);
  3511. +         return;
  3512. +     }
  3513. +     *dst = (char) ch;
  3514. + }
  3515. + /*
  3516. +  * Write bytes to kernel address space for debugger.
  3517. +  */
  3518. + void
  3519. + db_write_bytes(addr, size, data)
  3520. +     vm_offset_t    addr;
  3521. +     int    size;
  3522. +     char    *data;
  3523. + {
  3524. +     extern char    etext[] ;
  3525. +     char    *dst, *limit;
  3526. +     dst = (char *)addr;
  3527. +     limit = dst + size;
  3528. +     while (dst < limit) {
  3529. +         if (dst < etext)    /* kernel text starts at 0 */
  3530. +             db_write_text(dst, *data);
  3531. +         else
  3532. +             db_write_data(dst, *data);
  3533. +         dst++;
  3534. +         data++;
  3535. +     }
  3536. + }
  3537. *** old-NetBSD/src/sys/arch/amiga/amiga/genassym.c
  3538. --- NetBSD/src/sys/arch/amiga/amiga/genassym.c
  3539. ***************
  3540. *** 110,115 ****
  3541. --- 110,116 ----
  3542.       printf("#define\tT_TRAP15 %d\n", T_TRAP15);
  3543.       printf("#define\tPSL_S %d\n", PSL_S);
  3544.       printf("#define\tPSL_IPL7 %d\n", PSL_IPL7);
  3545. +     printf("#define\tPSL_IPL %d\n", PSL_IPL);
  3546.       printf("#define\tPSL_LOWIPL %d\n", PSL_LOWIPL);
  3547.       printf("#define\tPSL_HIGHIPL %d\n", PSL_HIGHIPL);
  3548.       printf("#define\tPSL_USER %d\n", PSL_USER);
  3549. *** old-NetBSD/src/sys/arch/amiga/amiga/isr.h
  3550. --- NetBSD/src/sys/arch/amiga/amiga/isr.h
  3551. ***************
  3552. *** 41,46 ****
  3553. --- 41,47 ----
  3554.       int    (*isr_intr)();
  3555.       void    *isr_arg;
  3556.       int    isr_ipl;
  3557. +     int    isr_mapped_ipl;
  3558.   };
  3559.   
  3560.   #define    NISR        3
  3561. *** old-NetBSD/src/sys/arch/amiga/amiga/kdassert.h
  3562. --- NetBSD/src/sys/arch/amiga/amiga/kdassert.h
  3563. ***************
  3564. *** 53,55 ****
  3565. --- 53,56 ----
  3566.   #define KDASSERT(x)
  3567.   #endif /* !DEBUG */
  3568.   #endif /* _KDASSERT_H */
  3569. *** old-NetBSD/src/sys/arch/amiga/amiga/locore.s
  3570. --- NetBSD/src/sys/arch/amiga/amiga/locore.s
  3571. ***************
  3572. *** 49,62 ****
  3573.   #include "assym.s"
  3574.   #include <amiga/amiga/vectors.s>
  3575.   #include <amiga/amiga/custom.h>
  3576.   
  3577.   #define CIAAADDR(ar)    movl    _CIAAbase,ar
  3578.   #define CIABADDR(ar)    movl    _CIABbase,ar
  3579.   #define CUSTOMADDR(ar)    movl    _CUSTOMbase,ar
  3580.   #define INTREQRADDR(ar)    movl    _INTREQRaddr,ar
  3581.   #define INTREQWADDR(ar)    movl    _INTREQWaddr,ar
  3582. ! #define INTENAWADDR(ar) movl    _amiga_intena_write,ar
  3583. ! #define    INTENARADDR(ar)    movl    _amiga_intena_read,ar
  3584.   
  3585.       .text
  3586.   /*
  3587. --- 49,62 ----
  3588.   #include "assym.s"
  3589.   #include <amiga/amiga/vectors.s>
  3590.   #include <amiga/amiga/custom.h>
  3591. + #include "ser.h"
  3592.   
  3593.   #define CIAAADDR(ar)    movl    _CIAAbase,ar
  3594.   #define CIABADDR(ar)    movl    _CIABbase,ar
  3595.   #define CUSTOMADDR(ar)    movl    _CUSTOMbase,ar
  3596.   #define INTREQRADDR(ar)    movl    _INTREQRaddr,ar
  3597.   #define INTREQWADDR(ar)    movl    _INTREQWaddr,ar
  3598. ! #define INTENAWADDR(ar) movl    _INTENAWaddr,a0
  3599.   
  3600.       .text
  3601.   /*
  3602. ***************
  3603. *** 473,482 ****
  3604.    * Interrupt handlers.
  3605.    *
  3606.    *    Level 0:    Spurious: ignored.
  3607. !  *    Level 1:    builtin-RS232 TBE, softint (not used yet)
  3608.    *    Level 2:    keyboard (CIA-A) + DMA + SCSI
  3609.    *    Level 3:    VBL
  3610. !  *    Level 4:    not used
  3611.    *    Level 5:    builtin-RS232 RBF
  3612.    *    Level 6:    Clock (CIA-B-Timers)
  3613.    *    Level 7:    Non-maskable: shouldn't be possible. ignore.
  3614. --- 473,482 ----
  3615.    * Interrupt handlers.
  3616.    *
  3617.    *    Level 0:    Spurious: ignored.
  3618. !  *    Level 1:    builtin-RS232 TBE, softint
  3619.    *    Level 2:    keyboard (CIA-A) + DMA + SCSI
  3620.    *    Level 3:    VBL
  3621. !  *    Level 4:    Audio
  3622.    *    Level 5:    builtin-RS232 RBF
  3623.    *    Level 6:    Clock (CIA-B-Timers)
  3624.    *    Level 7:    Non-maskable: shouldn't be possible. ignore.
  3625. ***************
  3626. *** 486,492 ****
  3627.    * and serial RBF (int5) specially, to improve performance
  3628.    */
  3629.   
  3630. !     .globl    _intrhand, _hardclock
  3631.   
  3632.   _spurintr:
  3633.       addql    #1,_intrcnt+0
  3634. --- 486,493 ----
  3635.    * and serial RBF (int5) specially, to improve performance
  3636.    */
  3637.   
  3638. !     .globl    _intrhand
  3639. !     .globl    _hardclock
  3640.   
  3641.   _spurintr:
  3642.       addql    #1,_intrcnt+0
  3643. ***************
  3644. *** 495,501 ****
  3645.   
  3646.   _lev5intr:
  3647.       moveml    d0/d1/a0/a1,sp@-
  3648. - #include "ser.h"
  3649.   #if NSER > 0
  3650.       jsr    _ser_fastint
  3651.   #else
  3652. --- 496,501 ----
  3653. ***************
  3654. *** 510,520 ****
  3655.   _lev1intr:
  3656.   _lev2intr:
  3657.   _lev3intr:
  3658. - #ifndef LEV6_DEFER
  3659.   _lev4intr:
  3660. ! #endif
  3661. !     moveml    #0xC0C0,sp@-
  3662. ! Lintrcommon:
  3663.       lea    _intrcnt,a0
  3664.       movw    sp@(22),d0        | use vector offset
  3665.       andw    #0xfff,d0        |   sans frame type
  3666. --- 510,517 ----
  3667.   _lev1intr:
  3668.   _lev2intr:
  3669.   _lev3intr:
  3670.   _lev4intr:
  3671. !     moveml    d0/d1/a0/a1,sp@-    | save scratch regs
  3672.       lea    _intrcnt,a0
  3673.       movw    sp@(22),d0        | use vector offset
  3674.       andw    #0xfff,d0        |   sans frame type
  3675. ***************
  3676. *** 523,622 ****
  3677.       clrw    sp@-            |    padded to longword
  3678.       jbsr    _intrhand        | handle interrupt
  3679.       addql    #4,sp            | pop SR
  3680. !     moveml    sp@+,#0x0303
  3681.       addql    #1,_cnt+V_INTR
  3682.       jra    rei
  3683.   
  3684.   _lev6intr:
  3685. ! #ifdef LEV6_DEFER
  3686. !     /*
  3687. !      * cause a level 4 interrupt (AUD3) to occur as soon
  3688. !      * as we return. Block generation of level 6 ints until
  3689. !      * we have dealt with this one.
  3690. !      */
  3691. !     moveml    #0x8080,sp@-
  3692.       INTREQRADDR(a0)
  3693.       movew    a0@,d0
  3694. !     btst    #INTB_EXTER,d0
  3695. !     jeq    Llev6spur
  3696. !     INTREQWADDR(a0)
  3697. !     movew    #INTF_SETCLR+INTF_AUD3,a0@
  3698. !     INTENAWADDR(a0)
  3699. !     movew    #INTF_EXTER,a0@
  3700. !     movew    #INTF_SETCLR+INTF_AUD3,a0@    | make sure THIS one is ok...
  3701. !     moveml    sp@+,#0x0101
  3702. !     rte
  3703. ! Llev6spur:
  3704. !     addql    #1,_intrcnt+36        | count spurious level 6 interrupts
  3705. !     moveml    sp@+,#0x0101
  3706. !     rte
  3707. ! _lev4intr:
  3708. ! _fake_lev6intr:
  3709. ! #endif
  3710. !     moveml    #0xC0C0,sp@-
  3711. ! #ifdef LEV6_DEFER
  3712. !     /*
  3713. !      * check for fake level 6
  3714. !      */
  3715. !     INTREQRADDR(a0)
  3716. !     movew    a0@,d0
  3717. !     btst    #INTB_EXTER,d0
  3718. !     jeq    Lintrcommon        | if EXTER not pending, handle normally
  3719. ! #endif
  3720. !     CIABADDR(a0)
  3721. !     movb    a0@(CIAICR),d0        | read irc register (clears ints!)
  3722. !     tstb    d0            | check if CIAB was source
  3723. !     jeq    Lchkexter        | no, go through isr chain
  3724. !     INTREQWADDR(a0)
  3725. ! #ifndef LEV6_DEFER
  3726. !     movew    #INTF_EXTER,a0@        | clear EXTER interrupt in intreq
  3727. ! #else
  3728. !     movew    #INTF_EXTER+INTF_AUD3,a0@ | clear EXTER & AUD3 in intreq
  3729.       INTENAWADDR(a0)
  3730. !     movew    #INTF_SETCLR+INTF_EXTER,a0@ | reenable EXTER interrupts
  3731. ! #endif
  3732. !     btst    #0,d0            | timerA interrupt?
  3733. !     jeq     Lskipciab        | no
  3734. ! | save d0 if we want to check other CIAB interrupts?
  3735. !     lea    sp@(16),a1        | get pointer to PS
  3736. !     movl    a1,sp@-            | push pointer to PS, PC
  3737. !     jbsr    _hardclock        | call generic clock int routine
  3738. !     addql    #4,sp            | pop params
  3739. !     addql    #1,_intrcnt+32        | add another system clock interrupt
  3740. ! Lskipciab:
  3741. ! | process any other CIAB interrupts?
  3742. ! Llev6done:
  3743. !     moveml    sp@+,#0x0303        | restore scratch regs
  3744.       addql    #1,_cnt+V_INTR        | chalk up another interrupt
  3745. !     jra    rei            | all done [can we do rte here?]
  3746. ! Lchkexter:
  3747. ! | check to see if EXTER request is really set?
  3748. !     movl    _isr_exter,a0        | get head of EXTER isr chain
  3749. ! Lnxtexter:
  3750. !     movl    a0,d0            | test if any more entries
  3751. !     jeq    Lexterdone        | (spurious interrupt?)
  3752. !     movl    a0,sp@-            | save isr pointer
  3753. !     movl    a0@(ISR_ARG),sp@-
  3754. !     movl    a0@(ISR_INTR),a0
  3755. !     jsr    a0@            | call isr handler
  3756. !     addql    #4,sp
  3757. !     movl    sp@+,a0            | restore isr pointer
  3758. !     movl    a0@(ISR_FORW),a0    | get next pointer
  3759. !     tstl    d0            | did handler process the int?
  3760. !     jeq    Lnxtexter        | no, try next
  3761. ! Lexterdone:
  3762. !     INTREQWADDR(a0)
  3763. ! #ifndef LEV6_DEFER
  3764. !     movew    #INTF_EXTER,a0@        | clear EXTER interrupt
  3765. ! #else
  3766. !     movew    #INTF_EXTER+INTF_AUD3,a0@ | clear EXTER & AUD3 interrupt
  3767. !     INTENAWADDR(a0)
  3768. !     movew    #INTF_SETCLR+INTF_EXTER,a0@ | reenable EXTER interrupts
  3769. ! #endif
  3770. !     addql    #1,_intrcnt+24        | count EXTER interrupts
  3771. !     jra    Llev6done
  3772.   
  3773.   _lev7intr:
  3774.       addql    #1,_intrcnt+28
  3775. --- 520,560 ----
  3776.       clrw    sp@-            |    padded to longword
  3777.       jbsr    _intrhand        | handle interrupt
  3778.       addql    #4,sp            | pop SR
  3779. !     moveml    sp@+,d0/d1/a0/a1    | restore scratch regs
  3780.       addql    #1,_cnt+V_INTR
  3781.       jra    rei
  3782.   
  3783. +     .globl    _isr_exter_ipl
  3784. +     .globl    _isr_exter_highipl
  3785. +     .globl    _isr_exter_lowipl
  3786. +     .globl    _hardclock_frame
  3787. +     
  3788.   _lev6intr:
  3789. !     moveml    d0-d1/a0-a1,sp@-    | save clobbered regs
  3790. ! #if 0
  3791.       INTREQRADDR(a0)
  3792.       movew    a0@,d0
  3793. !     btst    #INTB_EXTER,d0        | check for non-EXTER INT6 ints
  3794. !     jne    Lexter
  3795. !     | register spurious int6 interrupt
  3796. ! Lexter:    
  3797. ! #endif
  3798. !     moveal    #_hardclock_frame,a0    | store the clockframe
  3799. !     movel    sp@(16),a0@+        | where hardclock will find it
  3800. !     movel    sp@(20),a0@
  3801.       INTENAWADDR(a0)
  3802. !     movew    #INTF_EXTER,a0@        | disable EXTER ints
  3803. !     movew    sp@(16),d0        | get PS-word
  3804. !     andl    #PSL_IPL,d0        | only IPL is interesting
  3805. !     orw    #PSL_S,d0        | note we're in kernel mode
  3806. !     movel    d0,sp@-
  3807. !     movel    _isr_exter_highipl,sp@-    | start out at the highest IPL
  3808. !     jbsr    _walk_ipls        | run all ISRs at appropriate IPLs
  3809. !     addql    #8,sp
  3810. !     addql    #1,_intrcnt+24        | add another exter interrupt
  3811. !     moveml    sp@+,d0-d1/a0-a1    | restore scratch regs
  3812.       addql    #1,_cnt+V_INTR        | chalk up another interrupt
  3813. !     jra    Lastchk            | all done [can we do rte here?]
  3814.   
  3815.   _lev7intr:
  3816.       addql    #1,_intrcnt+28
  3817. ***************
  3818. *** 627,633 ****
  3819.        */
  3820.       rte                | all done
  3821.   
  3822.   /*
  3823.    * Emulation of VAX REI instruction.
  3824.    *
  3825. --- 565,570 ----
  3826. ***************
  3827. *** 653,658 ****
  3828. --- 590,607 ----
  3829.       tstl    _panicstr        | have we paniced?
  3830.       jne    Ldorte            | yes, do not make matters worse
  3831.   #endif
  3832. +     tstl    _isr_exter_ipl        | IPL lowering in process?
  3833. +     jeq    Lastchk            | no, go on to check for ASTs
  3834. +     moveml    d0-d1/a0-a1,sp@-    | save scratch regs
  3835. +     movw    sp@(16),d0        | get PS
  3836. +     andl    #PSL_IPL,d0        | we're only interested in the IPL
  3837. +     orw    #PSL_S,d0        | note that we're in kernel mode
  3838. +     movel    d0,sp@-
  3839. +     movel    _isr_exter_ipl,sp@-    | start where we left last walk_ipls
  3840. +     jbsr    _walk_ipls        | run needed ISRs
  3841. +     addql    #8,sp            | pop params
  3842. +     moveml    sp@+,d0-d1/a0-a1    | restore scratch regs
  3843. + Lastchk:    
  3844.       tstl    _astpending        | AST pending?
  3845.       jeq    Ldorte            | no, done
  3846.   Lrei1:
  3847. ***************
  3848. *** 737,742 ****
  3849. --- 686,697 ----
  3850.       movl    #0xbfd000,_CIABbase
  3851.       movl    #0xdff000,_CUSTOMbase
  3852.   
  3853. + #ifdef BOOT_DEBUG
  3854. +     movl    #0xfff,sp@-
  3855. +     jbsr    _rollcolor
  3856. +     addql    #4,sp
  3857. + #endif
  3858.       /*
  3859.        * initialize the timer frequency
  3860.        */
  3861. ***************
  3862. *** 2102,2119 ****
  3863.   /* interrupt counters */
  3864.       .globl    _intrcnt,_eintrcnt,_intrnames,_eintrnames
  3865.   _intrnames:
  3866. !     .asciz    "spur"        | spurious interrupt
  3867. !     .asciz    "tbe/soft"    | serial TBE & software
  3868. !     .asciz    "kbd/ports"    | keyboard & PORTS
  3869. !     .asciz    "vbl"        | vertical blank
  3870. !     .asciz    "audio"        | audio channels
  3871. !     .asciz    "rbf"        | serial receive
  3872. !     .asciz    "exter"        | EXTERN
  3873. !     .asciz    "nmi"        | non-maskable
  3874. !     .asciz    "clock"        | clock interrupts
  3875. !     .asciz    "spur6"        | spurious level 6
  3876.   _eintrnames:
  3877.       .align    2
  3878.   _intrcnt:
  3879. !     .long    0,0,0,0,0,0,0,0,0,0
  3880.   _eintrcnt:
  3881. --- 2057,2072 ----
  3882.   /* interrupt counters */
  3883.       .globl    _intrcnt,_eintrcnt,_intrnames,_eintrnames
  3884.   _intrnames:
  3885. !     .asciz    "spur"
  3886. !     .asciz    "tbe/soft"
  3887. !     .asciz    "kbd/ports"
  3888. !     .asciz    "vbl"
  3889. !     .asciz    "audio"
  3890. !     .asciz    "rbf"
  3891. !     .asciz    "exter"
  3892. !     .asciz    "nmi"
  3893.   _eintrnames:
  3894.       .align    2
  3895.   _intrcnt:
  3896. !     .long    0,0,0,0,0,0,0,0,0
  3897.   _eintrcnt:
  3898. *** old-NetBSD/src/sys/arch/amiga/amiga/machdep.c
  3899. --- NetBSD/src/sys/arch/amiga/amiga/machdep.c
  3900. ***************
  3901. *** 138,144 ****
  3902.   /* the following is used externally (sysctl_hw) */
  3903.   char machine[] = "amiga";
  3904.    
  3905. !  /*
  3906.    * Console initialization: called early on from main,
  3907.    * before vm init or startup.  Do enough configuration
  3908.    * to choose and initialize a console.
  3909. --- 138,184 ----
  3910.   /* the following is used externally (sysctl_hw) */
  3911.   char machine[] = "amiga";
  3912.    
  3913. ! struct isr *isr_ports;
  3914. ! struct isr *isr_exter[7];
  3915. ! int isr_exter_lowipl = 7;
  3916. ! int isr_exter_highipl = 0;
  3917. ! int isr_exter_ipl = 0;
  3918. ! /*
  3919. !  * Poll all registered ISRs starting at IPL start_ipl going down to
  3920. !  * isr_exter_lowipl.  If we reach the IPL of ending_psw along the way
  3921. !  * just return stating in isr_exter_ipl that we need to run the remaining
  3922. !  * layers later when the IPL gets lowered (i.e. a spl? call).  If some
  3923. !  * ISR handles the interrupt, or all layers have been processed, enable
  3924. !  * EXTER interrupts again and return.
  3925. !  */
  3926. ! void
  3927. ! walk_ipls (start_ipl, ending_psw)
  3928. !     int start_ipl;
  3929. !     int ending_psw;
  3930. ! {
  3931. !     int i;
  3932. !     int handled = 0;
  3933. !     for (i = start_ipl; !handled && i >= isr_exter_lowipl; i--) {
  3934. !         register int psw = i << 8 | PSL_S;
  3935. !         struct isr *isr;
  3936. !               
  3937. !         if (psw <= ending_psw) {
  3938. !             isr_exter_ipl = i;
  3939. !             return;
  3940. !         }
  3941. !         __asm __volatile("movew %0,sr" : : "d" (psw) : "cc");
  3942. !         for (isr = isr_exter[i]; !handled && isr; isr = isr->isr_forw)
  3943. !             handled = (*isr->isr_intr)(isr->isr_arg);
  3944. !     }
  3945. !     isr_exter_ipl = 0;
  3946. !     __asm __volatile("movew %0,sr" : : "di" (PSL_S|PSL_IPL6) : "cc");
  3947. !     custom.intreq = INTF_EXTER;
  3948. !     custom.intena = INTF_SETCLR | INTF_EXTER;
  3949. ! }
  3950. ! /*
  3951.    * Console initialization: called early on from main,
  3952.    * before vm init or startup.  Do enough configuration
  3953.    * to choose and initialize a console.
  3954. ***************
  3955. *** 1078,1094 ****
  3956.    * function calls executed at very low interrupt priority.
  3957.    * Example for use is keyboard repeat, where the repeat 
  3958.    * handler running at splclock() triggers such a (hardware
  3959. !  * aided) software interrupt.
  3960. !  * Note: the installed functions are currently called in a
  3961. !  * LIFO fashion, might want to change this to FIFO
  3962. !  * later.
  3963.    */
  3964.   struct si_callback {
  3965.       struct si_callback *next;
  3966.       void (*function) __P((void *rock1, void *rock2));
  3967.       void *rock1, *rock2;
  3968.   };
  3969.   static struct si_callback *si_callbacks;
  3970.   static struct si_callback *si_free;
  3971.   #ifdef DIAGNOSTIC
  3972.   static int ncb;        /* number of callback blocks allocated */
  3973. --- 1118,1134 ----
  3974.    * function calls executed at very low interrupt priority.
  3975.    * Example for use is keyboard repeat, where the repeat 
  3976.    * handler running at splclock() triggers such a (hardware
  3977. !  * aided) software interrupt.  These functions are called in
  3978. !  * a FIFO manner as expected.
  3979.    */
  3980.   struct si_callback {
  3981.       struct si_callback *next;
  3982.       void (*function) __P((void *rock1, void *rock2));
  3983.       void *rock1, *rock2;
  3984.   };
  3985.   static struct si_callback *si_callbacks;
  3986. + static struct si_callback *si_callbacks_end;
  3987.   static struct si_callback *si_free;
  3988.   #ifdef DIAGNOSTIC
  3989.   static int ncb;        /* number of callback blocks allocated */
  3990. ***************
  3991. *** 1147,1154 ****
  3992.       si->rock2 = rock2;
  3993.   
  3994.       s = splhigh();
  3995. !     si->next = si_callbacks;
  3996. !     si_callbacks = si;
  3997.       splx(s);
  3998.   
  3999.       /*
  4000. --- 1187,1198 ----
  4001.       si->rock2 = rock2;
  4002.   
  4003.       s = splhigh();
  4004. !     si->next = NULL;
  4005. !     if (si_callbacks)
  4006. !         si_callbacks_end->next = si;
  4007. !     else
  4008. !         si_callbacks = si;
  4009. !     si_callbacks_end = si;
  4010.       splx(s);
  4011.   
  4012.       /*
  4013. ***************
  4014. *** 1180,1185 ****
  4015. --- 1224,1231 ----
  4016.                   psi->next = nsi;
  4017.               else
  4018.                   si_callbacks = nsi;
  4019. +             if (si == si_callbacks_end)
  4020. +                 si_callbacks_end = psi;
  4021.           }
  4022.           si = nsi;
  4023.       }
  4024. ***************
  4025. *** 1197,1202 ****
  4026. --- 1243,1249 ----
  4027.   
  4028.       do {
  4029.           s = splhigh ();
  4030. +         /* Yes, that's an *assignment* below!  */
  4031.           if (si = si_callbacks)
  4032.               si_callbacks = si->next;
  4033.           splx(s);
  4034. ***************
  4035. *** 1224,1246 ****
  4036.   #endif
  4037.   }
  4038.   
  4039. - struct isr *isr_ports;
  4040. - struct isr *isr_exter;
  4041.   void
  4042.   add_isr(isr)
  4043.       struct isr *isr;
  4044.   {
  4045.       struct isr **p, *q;
  4046.   
  4047. !     p = isr->isr_ipl == 2 ? &isr_ports : &isr_exter;
  4048.       while ((q = *p) != NULL)
  4049.           p = &q->isr_forw;
  4050.       isr->isr_forw = NULL;
  4051.       *p = isr;
  4052.       /* enable interrupt */
  4053. !     custom.intena = isr->isr_ipl == 2 ? INTF_SETCLR | INTF_PORTS :
  4054. !         INTF_SETCLR | INTF_EXTER;
  4055.   }
  4056.   
  4057.   void
  4058. --- 1271,1296 ----
  4059.   #endif
  4060.   }
  4061.   
  4062.   void
  4063.   add_isr(isr)
  4064.       struct isr *isr;
  4065.   {
  4066.       struct isr **p, *q;
  4067.   
  4068. !     p = isr->isr_ipl == 2 ? &isr_ports : &isr_exter[isr->isr_mapped_ipl];
  4069. !     if (isr->isr_ipl == 6) {
  4070. !         if (isr->isr_mapped_ipl > isr_exter_highipl)
  4071. !             isr_exter_highipl = isr->isr_mapped_ipl;
  4072. !         if (isr->isr_mapped_ipl < isr_exter_lowipl)
  4073. !             isr_exter_lowipl = isr->isr_mapped_ipl;
  4074. !     }
  4075.       while ((q = *p) != NULL)
  4076.           p = &q->isr_forw;
  4077.       isr->isr_forw = NULL;
  4078.       *p = isr;
  4079.       /* enable interrupt */
  4080. !     custom.intena = INTF_SETCLR |
  4081. !         (isr->isr_ipl == 2 ? INTF_PORTS : INTF_EXTER);
  4082.   }
  4083.   
  4084.   void
  4085. ***************
  4086. *** 1249,1255 ****
  4087.   {
  4088.       struct isr **p, *q;
  4089.   
  4090. !     p = isr->isr_ipl == 6 ? &isr_exter : &isr_ports;
  4091.       while ((q = *p) != NULL && q != isr)
  4092.           p = &q->isr_forw;
  4093.       if (q)
  4094. --- 1299,1305 ----
  4095.   {
  4096.       struct isr **p, *q;
  4097.   
  4098. !     p = isr->isr_ipl == 6 ? &isr_exter[isr->isr_mapped_ipl] : &isr_ports;
  4099.       while ((q = *p) != NULL && q != isr)
  4100.           p = &q->isr_forw;
  4101.       if (q)
  4102. ***************
  4103. *** 1257,1265 ****
  4104.       else
  4105.           panic("remove_isr: handler not registered");
  4106.       /* disable interrupt if no more handlers */
  4107. !     p = isr->isr_ipl == 6 ? &isr_exter : &isr_ports;
  4108. !     if (*p == NULL)
  4109. !         custom.intena = isr->isr_ipl == 6 ? INTF_EXTER : INTF_PORTS;
  4110.   }
  4111.   
  4112.   intrhand(sr)
  4113. --- 1307,1328 ----
  4114.       else
  4115.           panic("remove_isr: handler not registered");
  4116.       /* disable interrupt if no more handlers */
  4117. !     p = isr->isr_ipl == 6 ? &isr_exter[isr->isr_mapped_ipl] : &isr_ports;
  4118. !     if (*p == NULL) {
  4119. !         if (isr->isr_ipl == 6) {
  4120. !             if (isr->isr_mapped_ipl == isr_exter_lowipl)
  4121. !                 while (isr_exter_lowipl++ < 6 &&
  4122. !                     !isr_exter[isr_exter_lowipl])
  4123. !                     ;
  4124. !             if (isr->isr_mapped_ipl == isr_exter_ipl)
  4125. !                 while (isr_exter_highipl-- > 0 &&
  4126. !                     !isr_exter[isr_exter_highipl])
  4127. !                     ;
  4128. !             if (isr_exter_lowipl == 7)
  4129. !                 custom.intena = INTF_EXTER;
  4130. !         } else if (isr->isr_ipl == 2)
  4131. !             custom.intena = INTF_PORTS;
  4132. !     }
  4133.   }
  4134.   
  4135.   intrhand(sr)
  4136. ***************
  4137. *** 1292,1298 ****
  4138.               /*
  4139.                * first clear the softint-bit
  4140.                * then process all classes of softints.
  4141. !              * this order is dicated by the nature of 
  4142.                * software interrupts.  The other order
  4143.                * allows software interrupts to be missed
  4144.                */
  4145. --- 1355,1361 ----
  4146.               /*
  4147.                * first clear the softint-bit
  4148.                * then process all classes of softints.
  4149. !              * this order is dictated by the nature of 
  4150.                * software interrupts.  The other order
  4151.                * allows software interrupts to be missed
  4152.                */
  4153. ***************
  4154. *** 1329,1339 ****
  4155.           break;
  4156.       case 3: 
  4157.         /* VBL */
  4158. !         if (ireq & INTF_BLIT)  
  4159.               blitter_handler();
  4160. !         if (ireq & INTF_COPER)  
  4161.               copper_handler();
  4162. !         if (ireq & INTF_VERTB) 
  4163.               vbl_handler();
  4164.           break;
  4165.   #if 0
  4166. --- 1392,1402 ----
  4167.           break;
  4168.       case 3: 
  4169.         /* VBL */
  4170. !         if (ireq & INTF_BLIT)
  4171.               blitter_handler();
  4172. !         if (ireq & INTF_COPER)
  4173.               copper_handler();
  4174. !         if (ireq & INTF_VERTB)
  4175.               vbl_handler();
  4176.           break;
  4177.   #if 0
  4178. ***************
  4179. *** 1422,1428 ****
  4180.   
  4181.       if (doingdump)
  4182.           return;
  4183. !     s = splhigh();
  4184.       doingdump = 1;
  4185.       printf("pid = %d, pc = %s, ", curproc->p_pid, hexstr(fp->f_pc, 8));
  4186.       printf("ps = %s, ", hexstr(fp->f_sr, 4));
  4187. --- 1485,1491 ----
  4188.   
  4189.       if (doingdump)
  4190.           return;
  4191. !     s = spl7();
  4192.       doingdump = 1;
  4193.       printf("pid = %d, pc = %s, ", curproc->p_pid, hexstr(fp->f_pc, 8));
  4194.       printf("ps = %s, ", hexstr(fp->f_sr, 4));
  4195. ***************
  4196. *** 1528,1530 ****
  4197. --- 1591,1599 ----
  4198.   #endif
  4199.       return(error);
  4200.   }
  4201. + #ifdef SPL_PROF
  4202. + struct _spl_ent _spl_stack[256];
  4203. + struct _spl_ent *_spl_p = _spl_stack;
  4204. + int spl_debug = 0, spl_prof = 0;
  4205. + #endif
  4206. *** old-NetBSD/src/sys/arch/amiga/amiga/trap.c
  4207. --- NetBSD/src/sys/arch/amiga/amiga/trap.c
  4208. ***************
  4209. *** 219,224 ****
  4210. --- 219,225 ----
  4211.       struct frame *fp;
  4212.   {
  4213.       static int panicing = 0;
  4214.       if (panicing++ == 0) {
  4215.           printf("trap type %d, code = %x, v = %x\n", type, code, v);
  4216.           regdump(fp, 128);
  4217. ***************
  4218. *** 638,647 ****
  4219. --- 639,650 ----
  4220.           return;
  4221.       }
  4222.   
  4223. + #if 0
  4224.   #ifdef DEBUG
  4225.       if (i != SIGTRAP)
  4226.           printf("trapsignal(%d, %d, %d, %x, %x)\n", p->p_pid, i,
  4227.               ucode, v, frame.f_regs[PC]);
  4228. + #endif
  4229.   #endif
  4230.       trapsignal(p, i, ucode);
  4231.       if ((type & T_USER) == 0)
  4232. *** /dev/null
  4233. --- NetBSD/src/sys/arch/amiga/conf/FILIPPA
  4234. ***************
  4235. *** 0 ****
  4236. --- 1,255 ----
  4237. + #    $NetBSD: FILIPPA,v 1.29 1994/12/01 17:24:44 chopps Exp $
  4238. + #
  4239. + # FILIPPA (AMIGA 2000 with a Zeus, a GVP HC-8, a Retina and a GoldenGate II)
  4240. + #
  4241. + # This configuration file contains all possible options
  4242. + #
  4243. + include "std.amiga"
  4244. + maxusers    8
  4245. + options        TIMEZONE=60, DST=1
  4246. + #
  4247. + # processors this kernel should support
  4248. + #
  4249. + options        "M68040"    # support for 040
  4250. + options        FPSP        # MC68040 floating point support
  4251. + #options        "M68030"    # support for 030
  4252. + #options        "M68020"    # support for 020/851
  4253. + options        FPCOPROC    # Support for MC6888[12] (Required)
  4254. + options        SWAPPAGER    # Pager for processes (Required)
  4255. + options        VNODEPAGER    # Pager for vnodes (Required)
  4256. + options        DEVPAGER    # Pager for devices (Required)
  4257. + #
  4258. + # Networking options
  4259. + #
  4260. + options        INET        # IP networking support (Required)
  4261. + #options        ISO        # ISO Networking support
  4262. + #options        TPIP        # ARGO TP networking support
  4263. + #options    CCITT        # CCITT X.25
  4264. + #options    NS        # Xerox XNS
  4265. + #options    EON        # ISO CLNL over IP
  4266. + options    GATEWAY            # Packet forwarding
  4267. + options    DIRECTED_BROADCAST    # Broadcast across subnets
  4268. + #options    NSIP        # XNS over IP
  4269. + #
  4270. + # File system related options
  4271. + #
  4272. + #options        QUOTA        # Disk quotas for local disks
  4273. + options        NFSSERVER    # Network File System server side code
  4274. + options        NFSCLIENT    # Network File System client side code
  4275. + #
  4276. + # File systems
  4277. + #
  4278. + options        FFS        # Berkeley fast file system
  4279. + options        MFS        # Memory based filesystem
  4280. + options        PROCFS        # Process filesystem
  4281. + options        KERNFS        # Kernel parameter filesystem (Recommended)
  4282. + options        FDESC        # /dev/fd filesystem
  4283. + options        NULLFS        # Loopback filesystem
  4284. + options        FIFO        # FIFO operations on vnodes (Recommended)
  4285. + options        ADOSFS        # AmigaDOS file system
  4286. + options        UNION
  4287. + #options        UMAPFS        # The umap layer
  4288. + #options        MSDOSFS        # MS-DOS filesystem
  4289. + options        "CD9660"        # ISO 9660 file system, with Rock Ridge
  4290. + #options        PORTAL        # Portal filesystem
  4291. + #
  4292. + # Compatability options for various existing systems
  4293. + #
  4294. + options        "COMPAT_10"    # compatability with older NetBSD release
  4295. + #options        "COMPAT_09"    # compatability with older NetBSD release
  4296. + options        "COMPAT_43"    # 4.3 BSD compatible system calls
  4297. + #options        COMPAT_SUNOS    # Support to run Sun (m68k) executables
  4298. + #options        "TCP_COMPAT_42"    # Use 4.2 BSD style TCP
  4299. + options        "COMPAT_NOMID"    # allow nonvalid machine id executables
  4300. + #options    COMPAT_HPUX    # HP300 compatability
  4301. + #
  4302. + # Support for System V IPC facilities.
  4303. + #
  4304. + #options        SYSVSHM        # System V-like shared memory
  4305. + #options        SYSVMSG        # System V-like messages
  4306. + #options        SYSVSEM        # System V-like semaphores
  4307. + #
  4308. + # Support for various kernel options
  4309. + #
  4310. + #options        GENERIC        # Mini-root boot support
  4311. + options        LKM        # Loadable kernel modules
  4312. + options        KTRACE        # Add kernel tracing system call
  4313. + options        DIAGNOSTIC    # Add additional error checking code
  4314. + options        "NKMEMCLUSTERS=256"    # Size of kernel malloc area
  4315. + #
  4316. + # Misc. debugging options
  4317. + #
  4318. + options        PANICWAIT    # Require keystroke to dump/reboot
  4319. + options        DEBUG        # Add debugging statements
  4320. + options        DDB        # Kernel debugger
  4321. + #options    SYSCALL_DEBUG    # debug all syscalls.
  4322. + #options    SCSIDEBUG    # Add SCSI debugging statements
  4323. + #options    KGDB        # Kernel debugger (KGDB) support
  4324. + #options    PANICBUTTON    # Forced crash via keypress (???)
  4325. + options        ISAED_DEBUG    # ed ethernet driver dubugging
  4326. + #options        SPL_PROF    # time spl regions
  4327. + #
  4328. + # Amiga specific options
  4329. + #
  4330. + options        MACHINE_NONCONTIG    # Non-contiguous memory support
  4331. + options        RETINACONSOLE    # enable code to allow retina to be console
  4332. + #options        GRF_ECS        # Enhanced Chip Set
  4333. + options        GRF_NTSC    # NTSC
  4334. + options        GRF_PAL        # PAL
  4335. + #options        "GRF_A2024"    # Support for the A2024
  4336. + #options        GRF_AGA        # AGA chip set
  4337. + #options        GRF_CL5426    # Cirrus board support (not yet)
  4338. + #options        "KFONT_8X11"    # 8x11 font
  4339. + options        KFONT_CUSTOM
  4340. + options        EMULATE_3_BUTTONS    # Emulate a middle button
  4341. + options        LEV6_DEFER        # Defer handling of level 6 interrupts
  4342. + #grfcc0        at mainbus0        # custom chips
  4343. + grfrt0        at zbus0        # retina II
  4344. + #grfrh0        at zbus0        # retina III
  4345. + #grfcl0        at zbus0        # Picasso II/Piccalo/Spectrum
  4346. + #grf0        at grfcc0
  4347. + grf1        at grfrt0
  4348. + #grf2        at grfrh0
  4349. + #grf3        at grfcl0
  4350. + #ite0        at grf0            # terminal emulators for grf's
  4351. + ite1        at grf1            # terminal emulators for grf's
  4352. + #ite2        at grf2            # terminal emulators for grf's
  4353. + #ite3        at grf3            # terminal emulators for grf's
  4354. + #mfc0        at zbus0        # MultiFaceCard I/O board
  4355. + #mfcs0        at mfc0 unit 0        # MFC serial
  4356. + #mfcs1        at mfc0 unit 1        # MFC serial
  4357. + #mfcp0        at mfc0 unit 0        # MFC parallel [not available yet]
  4358. + #mfc1        at zbus0        # MultiFaceCard 2nd I/O board
  4359. + #mfcs2        at mfc1 unit 0
  4360. + #mfcs3        at mfc1 unit 1
  4361. + #mfcp1        at mfc1 unit 0
  4362. + #le0        at zbus0        # Lance ethernet.
  4363. + #zed0        at zbus0        # dp8390 ethernet
  4364. + #zes0        at zbus0        # SMC 91C90 ethernet
  4365. + # scsi stuff, all possible
  4366. + #gvpbus0        at zbus0
  4367. + #gtsc0        at gvpbus0        # GVP series II scsi
  4368. + #gvpbus1        at zbus0
  4369. + #gtsc1        at gvpbus1        # GVP series II scsi
  4370. + #ahsc0        at mainbus0        # A3000 scsi
  4371. + #atzsc0        at zbus0
  4372. + #wstsc0        at zbus0        # Wordsync II scsi
  4373. + #ivsc0        at zbus0        # IVS scsi
  4374. + #mlhsc0        at zbus0        # Hacker scsi
  4375. + #otgsc0        at zbus0        # 12 gauge scsi
  4376. + zssc0        at zbus0        # Zeus scsi
  4377. + #mgnsc0        at zbus0        # Magnum scsi
  4378. + #wesc0        at zbus0        # Warp Engine scsi
  4379. + #idesc0        at mainbus0        # A4000(A1200?) IDE
  4380. + #afsc0        at zbus0        # A4091 scsi
  4381. + #flz3sc0        at zbus0        # FastlaneZ3 scsi
  4382. + #scsibus*    at gtsc?
  4383. + #scsibus*    at atzsc0
  4384. + #scsibus*    at wstsc0
  4385. + #scsibus*    at ivsc0
  4386. + #scsibus*    at mlhsc0
  4387. + #scsibus*    at otgsc0
  4388. + scsibus*    at zssc0
  4389. + #scsibus*    at mgnsc0
  4390. + #scsibus*    at wesc0
  4391. + #scsibus*    at idesc0
  4392. + #scsibus*    at afsc0
  4393. + #scsibus*    at flz3sc0
  4394. + #
  4395. + # compat.
  4396. + #
  4397. + #sd0    at scsibus? target 0 lun 0
  4398. + #sd1    at scsibus? target 1 lun 0
  4399. + #sd2    at scsibus? target 2 lun 0
  4400. + #sd3    at scsibus? target 3 lun 0
  4401. + #sd4    at scsibus? target 4 lun 0
  4402. + #sd5    at scsibus? target 5 lun 0
  4403. + #sd6    at scsibus? target 6 lun 0
  4404. + #sd7    at scsibus? target 7 lun 0
  4405. + #sd8    at scsibus? target 0 lun 0
  4406. + #sd9    at scsibus? target 1 lun 0
  4407. + #sd10    at scsibus? target 2 lun 0
  4408. + #sd11    at scsibus? target 3 lun 0
  4409. + #sd12    at scsibus? target 4 lun 0
  4410. + #sd13    at scsibus? target 5 lun 0
  4411. + #sd14    at scsibus? target 6 lun 0
  4412. + #sd15    at scsibus? target 7 lun 0
  4413. + #
  4414. + # This is nicer however many amiga setups expect sd units to refer to
  4415. + # scsi target numbers.  If this is not the case, you can remove the 
  4416. + # specific sdx lines above and each hard drive from low target to high
  4417. + # will configure to the next available sd unit number
  4418. + sd*    at scsibus? target ? lun ?    # scsi disks
  4419. + st*    at scsibus? target ? lun ?    # scsi tapes
  4420. + cd*    at scsibus? target ? lun ?    # scsi cd's
  4421. + ggbus0    at zbus0            # Goldengate bridge
  4422. + isa*    at ggbus0
  4423. + #cross0    at zbus0            # CrossLink bridge
  4424. + #isa*    at cross0
  4425. + com0    at isa? port 0x3f8 irq 4    # Standard PC serial ports
  4426. + com1    at isa? port 0x2f8 irq 3
  4427. + com2    at isa? port 0x3e8 irq 5
  4428. + com3    at isa? port 0x2e8 irq 9
  4429. + #com0   at isa? port 0x0f0 irq 11    # Crosslink builtin ports
  4430. + #com1    at isa? port 0x0f8 irq 10
  4431. + ast0    at isa? port 0x1a0 irq 3    # AST 4-port serial cards
  4432. + #com*    at ast? slave ? flags 1
  4433. + com4    at ast? slave ? flags 1
  4434. + com5    at ast? slave ? flags 1
  4435. + com6    at ast? slave ? flags 1
  4436. + com7    at ast? slave ? flags 1
  4437. + lpt0    at isa? port 0x378 irq 7    # Standard PC arallel ports
  4438. + lpt1    at isa? port 0x278
  4439. + lpt2    at isa? port 0x3bc
  4440. + # XXX should be ed0
  4441. + isaed0    at isa? port 0x300 iomem 0xcc000 irq 10    # WD/SMC, 3C503, and NE[12]000
  4442. +                         #   ethernetcards
  4443. + fd*    at fdc0 unit ?
  4444. + #pseudo-device    mouse    1        # mouse
  4445. + pseudo-device    view 2            # views
  4446. + #pseudo-device    aconf            # autoconfig info
  4447. + pseudo-device    loop    1        # network loopback
  4448. + pseudo-device    bpfilter 8        # packet filter
  4449. + pseudo-device    sl    2        # CSLIP
  4450. + pseudo-device    ppp    2        # PPP
  4451. + pseudo-device    tun    2        # network tunneling over tty
  4452. + pseudo-device    pty    64        # pseudo-terminals
  4453. + pseudo-device    vnd    4        # paging to files
  4454. + #config    netbsd swap on generic
  4455. + config netbsd root on sd1a swap on sd1b and sd2b
  4456. *** old-NetBSD/src/sys/arch/amiga/conf/GENERIC
  4457. --- NetBSD/src/sys/arch/amiga/conf/GENERIC
  4458. ***************
  4459. *** 159,166 ****
  4460.   #mfcp1        at mfc1 unit 0
  4461.   
  4462.   le0        at zbus0        # Lance ethernet.
  4463. ! ed0        at zbus0        # dp8390 ethernet
  4464. ! es0        at zbus0        # SMC 91C90 ethernet
  4465.   ae0        at zbus0        # Ariadne ethernet
  4466.   
  4467.   # scsi stuff, all possible
  4468. --- 159,166 ----
  4469.   #mfcp1        at mfc1 unit 0
  4470.   
  4471.   le0        at zbus0        # Lance ethernet.
  4472. ! zed0        at zbus0        # dp8390 ethernet
  4473. ! zes0        at zbus0        # SMC 91C90 ethernet
  4474.   ae0        at zbus0        # Ariadne ethernet
  4475.   
  4476.   # scsi stuff, all possible
  4477. *** old-NetBSD/src/sys/arch/amiga/conf/Makefile.amiga
  4478. --- NetBSD/src/sys/arch/amiga/conf/Makefile.amiga
  4479. ***************
  4480. *** 33,39 ****
  4481.   S=    ../../../..
  4482.   AMIGA=    ../..
  4483.   
  4484. ! INCLUDES= -I. -I$S/arch -I$S -I$S/sys 
  4485.   COPTS=    ${INCLUDES} ${IDENT} -D_KERNEL -Dmc68020 -Damiga
  4486.   CFLAGS=    -O -mc68020 -m68881 ${COPTS}
  4487.   
  4488. --- 33,39 ----
  4489.   S=    ../../../..
  4490.   AMIGA=    ../..
  4491.   
  4492. ! INCLUDES= -I. -I../.. -I$S/arch -I$S -I$S/sys 
  4493.   COPTS=    ${INCLUDES} ${IDENT} -D_KERNEL -Dmc68020 -Damiga
  4494.   CFLAGS=    -O -mc68020 -m68881 ${COPTS}
  4495.   
  4496. *** /dev/null
  4497. --- NetBSD/src/sys/arch/amiga/conf/files.amiga.newconf
  4498. ***************
  4499. *** 0 ****
  4500. --- 1,259 ----
  4501. + #    $NetBSD: files.amiga.newconf,v 1.17 1995/02/12 19:18:57 chopps Exp $
  4502. + # maxpartitions must be first item in files.${ARCH}.newconf
  4503. + maxpartitions 16            # NOTE THAT AMIGA IS SPECIAL!
  4504. + maxusers 2 8 64
  4505. + device    mainbus at root {}
  4506. + device    cpu at mainbus
  4507. + # zorro II expansion bus.
  4508. + device    zbus at mainbus {}
  4509. + file    arch/amiga/dev/zbus.c        zbus
  4510. + define    event {}
  4511. + file    arch/amiga/dev/event.c        event
  4512. + device    clock at mainbus
  4513. + file    arch/amiga/dev/clock.c
  4514. + # keyboard
  4515. + device    kbd at mainbus: event
  4516. + file    arch/amiga/dev/kbd.c        kbd needs-flag
  4517. + # serial port
  4518. + device    ser at mainbus:    tty
  4519. + file    arch/amiga/dev/ser.c        ser needs-count
  4520. + # parellel port
  4521. + device    par at mainbus
  4522. + file    arch/amiga/dev/par.c        par needs-count
  4523. + # mouse
  4524. + pseudo-device    mouse
  4525. + file    arch/amiga/dev/ms.c        mouse needs-count
  4526. + device    fdc at mainbus { unit = -1 }
  4527. + device    fd at fdc
  4528. + file    arch/amiga/dev/fd.c        fd needs-flag
  4529. + major    {fd = 2}
  4530. + # graphic devices
  4531. + define    grfbus {}
  4532. + device    grf at grfbus {}
  4533. + file    arch/amiga/dev/grf.c        grf needs-count
  4534. + device    ite at grf
  4535. + file    arch/amiga/dev/ite.c        ite needs-flag
  4536. + file    arch/amiga/dev/kbdmap.c        ite
  4537. + file    arch/amiga/dev/kf_8x8.c        ite
  4538. + file    arch/amiga/dev/kf_8x11.c    kfont_8x11
  4539. + file    arch/amiga/dev/kf_custom.c    kfont_custom
  4540. + # custom chips grf
  4541. + device    grfcc at mainbus: grfbus
  4542. + file    arch/amiga/dev/grf_cc.c        grfcc needs-flag
  4543. + file    arch/amiga/dev/ite_cc.c        grfcc ite
  4544. + pseudo-device    view
  4545. + file    arch/amiga/dev/view.c        view grfcc needs-count
  4546. + file    arch/amiga/dev/grfabs.c        grfcc view
  4547. + file    arch/amiga/dev/grfabs_cc.c    grfcc view
  4548. + file    arch/amiga/dev/grfabs_ccglb.c    grfcc view
  4549. + # retina grf
  4550. + device    grfrt at zbus: grfbus
  4551. + file    arch/amiga/dev/grf_rt.c        grfrt needs-flag
  4552. + file    arch/amiga/dev/ite_rt.c        grfrt ite
  4553. + # cirrus grf
  4554. + device    grfcl at zbus: grfbus
  4555. + file    arch/amiga/dev/grf_cl.c        grfcl needs-flag
  4556. + # retina ZIII grf
  4557. + device    grfrh at zbus: grfbus
  4558. + file    arch/amiga/dev/grf_rh.c        grfrh needs-flag
  4559. + file    arch/amiga/dev/ite_rh.c        grfrh ite
  4560. +   
  4561. + # handle gvp's odd autoconf info..
  4562. + device    gvpbus at zbus {}
  4563. + file    arch/amiga/dev/gvpbus.c        gvpbus
  4564. + define    bridge {}
  4565. + # GoldenGate bridge
  4566. + device    ggbus at zbus: bridge
  4567. + file    arch/amiga/dev/ggbus.c        ggbus needs-flag
  4568. + # CrossLink bridge
  4569. + device    cross at zbus: bridge
  4570. + file    arch/amiga/dev/cross.c        cross needs-flag
  4571. + # Generic bridge driver
  4572. + device    isa at bridge {[port = -1], [size = 0],
  4573. +                [iomem = -1], [iosiz = 0],
  4574. +                [irq = -1], [drq = -1]}
  4575. + #
  4576. + # ISA drivers
  4577. + #
  4578. + file    arch/amiga/isa/isa.c        isa
  4579. + define    commulti {[slave = -1]}
  4580. + device    ast at isa: commulti
  4581. + file    dev/isa/ast.c            ast
  4582. + device    boca at isa: commulti
  4583. + file    dev/isa/boca.c            boca
  4584. + device    rtfps at isa: commulti
  4585. + file    dev/isa/rtfps.c            rtfps
  4586. + device    com at isa, commulti: tty
  4587. + file    dev/isa/com.c            com needs-count
  4588. + device    lpt at isa
  4589. + file    dev/isa/lpt.c            lpt needs-flag
  4590. + device    isaed at isa: ifnet, ether
  4591. + file    arch/amiga/isa/if_isaed.c    isaed
  4592. + #
  4593. + # Zorro devices again
  4594. + #
  4595. + device    zle at zbus:    ifnet, ether
  4596. + file    arch/amiga/dev/if_zle.c        zle needs-count
  4597. + device    zed at zbus:    ifnet, ether
  4598. + file    arch/amiga/dev/if_zed.c        zed needs-flag
  4599. + device    es at zbus:    ifnet, ether
  4600. + file    arch/amiga/dev/if_es.c        es needs-count
  4601. + # Alf Data MultiFaceCard 3
  4602. + #device    mfch at zbus: tty
  4603. + #file    arch/amiga/dev/mfch.c        mfch needs-count
  4604. + # bsc/Alf Data MultiFaceCard
  4605. + device    mfc at zbus { unit = -1 }
  4606. + device    mfcs at mfc
  4607. + device    mfcp at mfc
  4608. + file    arch/amiga/dev/mfc.c        mfcs mfcp needs-count
  4609. + define    scsi {}
  4610. + # wd 33c93 controllers
  4611. + define    sbic 
  4612. + file    arch/amiga/dev/sbic.c        sbic
  4613. + # C= A2091
  4614. + device atzsc at zbus: scsi, sbic
  4615. + file    arch/amiga/dev/atzsc.c        atzsc needs-flag
  4616. + # GVP series II
  4617. + device    gtsc at gvpbus: scsi, sbic
  4618. + file    arch/amiga/dev/gtsc.c        gtsc needs-flag
  4619. + # Amiga 3000 internal
  4620. + device    ahsc at mainbus: scsi, sbic
  4621. + file    arch/amiga/dev/ahsc.c        ahsc needs-flag
  4622. + # ncr 57c710 controllers
  4623. + define    siop
  4624. + file    arch/amiga/dev/siop.c        siop
  4625. + # PPI Zeus
  4626. + device    zssc at zbus: scsi, siop
  4627. + file    arch/amiga/dev/zssc.c        zssc needs-flag
  4628. + # CSA Magnum
  4629. + device    mgnsc at zbus: scsi, siop
  4630. + file    arch/amiga/dev/mgnsc.c        mgnsc needs-flag
  4631. + # MacroSystems Warp Engine
  4632. + device    wesc at zbus: scsi, siop
  4633. + file    arch/amiga/dev/wesc.c        wesc needs-flag
  4634. + # C= A4091
  4635. + device    afsc at zbus: scsi, siop
  4636. + file    arch/amiga/dev/afsc.c        afsc needs-flag
  4637. + # ncr 5380 controllers
  4638. + define    sci
  4639. + file    arch/amiga/dev/sci.c        sci
  4640. + # Supra Wordsync II
  4641. + device    wstsc at zbus: scsi, sci
  4642. + file    arch/amiga/dev/wstsc.c        wstsc needs-flag
  4643. + # IVS 
  4644. + device    ivsc at zbus: scsi, sci
  4645. + file    arch/amiga/dev/ivsc.c        ivsc needs-flag
  4646. + # CSA twelve gauge.
  4647. + device    otgsc at zbus: scsi, sci
  4648. + file    arch/amiga/dev/otgsc.c        otgsc needs-flag
  4649. + # MLH
  4650. + device    mlhsc at zbus: scsi, sci
  4651. + file    arch/amiga/dev/mlhsc.c        mlhsc needs-flag
  4652. + # Emulex ESP216 & FAS216 controllers
  4653. + define    fas
  4654. + file    arch/amiga/dev/fas.c        fas
  4655. + # FastlaneZ3
  4656. + device    flz3sc at zbus: scsi, fas
  4657. + file    arch/amiga/dev/flz3sc.c        flz3sc needs-flag
  4658. + # Amiga 4000/1200 IDE masquerading as SCSI
  4659. + device    idesc at mainbus: scsi
  4660. + file    arch/amiga/dev/idesc.c        idesc needs-flag
  4661. + device    scsibus at scsi    {target = -1, lun = -1}
  4662. + device    cd at scsibus: disk
  4663. + file    scsi/cd.c            cd needs-flag
  4664. + major    {cd = 6}
  4665. + device    sd at scsibus: disk
  4666. + file    scsi/sd.c            sd needs-flag
  4667. + major    {sd = 4}
  4668. + device    st at scsibus: tape
  4669. + file    scsi/st.c            st needs-flag
  4670. + major    {st = 5}
  4671. + device    ch at scsibus: disk
  4672. + file    scsi/ch.c            ch needs-flag
  4673. + device    uk at scsibus: disk
  4674. + file    scsi/uk.c            uk needs-flag
  4675. + device    su at scsibus: disk
  4676. + file    scsi/su.c            su needs-flag
  4677. + pseudo-device    aconf
  4678. + file    arch/amiga/dev/aconfdev.c        aconf
  4679. + # list of standard files...
  4680. + file    dev/cons.c            ite ser
  4681. + file    scsi/scsi_base.c        scsi
  4682. + file    scsi/scsi_ioctl.c        scsi
  4683. + file    scsi/scsiconf.c            scsi
  4684. + file    arch/amiga/amiga/amiga_init.c
  4685. + file    arch/amiga/amiga/autoconf.c
  4686. + file    arch/amiga/amiga/cia.c
  4687. + file    arch/amiga/amiga/conf.c
  4688. + file    arch/amiga/amiga/disksubr.c
  4689. + file    arch/amiga/amiga/dkbad.c
  4690. + file    arch/amiga/amiga/machdep.c
  4691. + file    arch/amiga/amiga/mem.c
  4692. + file    arch/amiga/amiga/pmap.c
  4693. + file    arch/amiga/amiga/sys_machdep.c
  4694. + file    arch/amiga/amiga/trap.c
  4695. + file    arch/amiga/amiga/vm_machdep.c
  4696. + file    arch/amiga/amiga/cc.c
  4697. + file    arch/amiga/amiga/db_memrw.c    ddb
  4698. + file    arch/m68k/m68k/copy.s
  4699. + file    compat/sunos/sunos_misc.c    compat_sunos
  4700. + file    compat/sunos/sunos_init_sysent.c    compat_sunos
  4701. + file    compat/sunos/sunos_ioctl.c    compat_sunos
  4702. + file    compat/sunos/sunos_exec.c    compat_sunos
  4703. *** /dev/null
  4704. --- NetBSD/src/sys/arch/amiga/dev/aconfdev.c
  4705. ***************
  4706. *** 0 ****
  4707. --- 1,168 ----
  4708. + /*
  4709. +  * Copyright (c) 1994 Endicor Technologies, Inc.
  4710. +  * All rights reserved.
  4711. +  *
  4712. +  * Redistribution and use in source and binary forms, with or without
  4713. +  * modification, are permitted provided that the following conditions
  4714. +  * are met:
  4715. +  * 1. Redistributions of source code must retain the above copyright
  4716. +  *    notice, this list of conditions and the following disclaimer.
  4717. +  * 2. Redistributions in binary form must reproduce the above copyright
  4718. +  *    notice, this list of conditions and the following disclaimer in the
  4719. +  *    documentation and/or other materials provided with the distribution.
  4720. +  * 3. All advertising materials mentioning features or use of this software
  4721. +  *    must display the following acknowledgement:
  4722. +  *    This product includes software developed by 
  4723. +  *    Endicor Technologies, Inc. and its contributors.
  4724. +  * 4. Neither the name of the Endicor nor the names of its contributors
  4725. +  *    may be used to endorse or promote products derived from this software
  4726. +  *    without specific prior written permission.
  4727. +  *
  4728. +  * THIS SOFTWARE IS PROVIDED BY ENDICOR AND CONTRIBUTORS ``AS IS'' AND
  4729. +  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  4730. +  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  4731. +  * ARE DISCLAIMED.  IN NO EVENT SHALL ENDICOR OR CONTRIBUTORS BE LIABLE
  4732. +  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  4733. +  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  4734. +  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  4735. +  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  4736. +  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  4737. +  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  4738. +  * SUCH DAMAGE.
  4739. +  *
  4740. +  *    $Id$
  4741. +  *
  4742. +  *    aconfdev.c -- driver for AUTOCONFIG (TM) information
  4743. +  *
  4744. +  *      AUTOCONFIG is a trademark of Commodore Electronics Limited.
  4745. +  */
  4746. + #include "aconf.h"
  4747. + #if NACONF > 0
  4748. + #include "sys/param.h"
  4749. + #include "sys/systm.h"
  4750. + #include "sys/ioctl.h"
  4751. + #include "sys/tty.h"
  4752. + #include "sys/proc.h"
  4753. + #include "sys/conf.h"
  4754. + #include "sys/file.h"
  4755. + #include "sys/uio.h"
  4756. + #include "sys/kernel.h"
  4757. + #include "sys/syslog.h"
  4758. + #include "device.h"
  4759. + #include "machine/cpu.h"
  4760. + #include "../amiga/configdev.h"
  4761. + #include "../amiga/memlist.h"
  4762. + /*ARGSUSED*/
  4763. + void
  4764. + aconfattach(n)
  4765. +     int n;
  4766. + {
  4767. + }
  4768. + /*ARGSUSED*/
  4769. + aconfioctl(dev, cmd, data, flag, p)
  4770. +     dev_t dev;
  4771. +     caddr_t data;
  4772. +     struct proc *p;
  4773. + {
  4774. +     extern struct Mem_List *mem_list;
  4775. +     extern int num_ConfigDev;
  4776. +     extern struct ConfigDev *ConfigDev;
  4777. +     struct amiga_hw *hw;
  4778. +     static int numhw = -1;
  4779. +     int error = 0;
  4780. +     if (numhw < 0) {
  4781. +         numhw = 0;
  4782. +                 for (hw = sc_table; hw->hw_type; hw++)
  4783. +                     numhw++;
  4784. +     }
  4785. +     switch (cmd) {
  4786. +     case ACIOCGINFO: {
  4787. +         struct ConfigInfo *ci = (struct ConfigInfo *)data;
  4788. +                     
  4789. +         ci->ci_NumConfigDev = num_ConfigDev;
  4790. +         ci->ci_NumHWDev = numhw;
  4791. +         ci->ci_NumMemSegs = mem_list->num_mem;
  4792. +         
  4793. +         ci->ci_CPUType = machineid;
  4794. +         ci->ci_CPUSpeed = cpuspeed;
  4795. +         ci->ci_MMUType = mmutype;
  4796. +         break;
  4797. +     }
  4798. +     case ACIOCGCDEV: {
  4799. +         struct ConfigDev *cd = (struct ConfigDev *)data;
  4800. +         int num;
  4801. +         num = cd->cd_Number;
  4802. +         if (num >= num_ConfigDev) {
  4803. +             error = EINVAL;
  4804. +         } else {
  4805. +             bcopy(  &ConfigDev[num],
  4806. +                 cd,
  4807. +                 sizeof(struct ConfigDev)
  4808. +             );            
  4809. +         }
  4810. +         break;
  4811. +     }
  4812. +     case ACIOCGAHWD: {
  4813. +         struct ConfigDev *cd = (struct ConfigDev *)data;
  4814. +         int num;
  4815. +         
  4816. +         num = cd->cd_Number;
  4817. +         if (num >= numhw) {
  4818. +             error = EINVAL;
  4819. +         } else {
  4820. +             bzero(cd, sizeof(ConfigDev));
  4821. +             
  4822. +             hw = &sc_table[num];
  4823. +             cd->cd_BoardAddr = hw->hw_pa;
  4824. +             cd->cd_BoardSize = hw->hw_size;
  4825. +             cd->cd_Rom.er_Manufacturer = hw->hw_manufacturer;
  4826. +             cd->cd_Rom.er_Product = hw->hw_product;
  4827. +             cd->cd_Rom.er_SerialNumber = hw->hw_serno;
  4828. +             cd->cd_Rom.er_Type = hw->hw_type;
  4829. +         }
  4830. +         break;
  4831. +     }
  4832. +     case ACIOCGMSEG: {
  4833. +         struct Mem_List *ml = (struct Mem_List *)data;
  4834. +         int num;
  4835. +         num = ml->num_mem;
  4836. +         if (num >= mem_list->num_mem) {
  4837. +             error = EINVAL;
  4838. +         } else {
  4839. +             bcopy(    &(mem_list->mem_seg[num]), 
  4840. +                 &(ml->mem_seg[0]), 
  4841. +                 sizeof(struct Mem_Seg)
  4842. +             );
  4843. +         }
  4844. +         break;
  4845. +     }
  4846. +     default:
  4847. +         error = EINVAL;
  4848. +         break;
  4849. +     }
  4850. +     return(error);
  4851. + }
  4852. + #endif    /* NACONF > 0 */
  4853. *** old-NetBSD/src/sys/arch/amiga/dev/ahsc.c
  4854. --- NetBSD/src/sys/arch/amiga/dev/ahsc.c
  4855. ***************
  4856. *** 110,119 ****
  4857.       volatile struct sdmac *rp;
  4858.       struct sbic_softc *sc;
  4859.       
  4860. -     printf("\n");
  4861.       sc = (struct sbic_softc *)dp;
  4862.       sc->sc_cregs = rp = ztwomap(0xdd0000);
  4863.       /*
  4864.        * disable ints and reset bank register
  4865.        */
  4866. --- 110,120 ----
  4867.       volatile struct sdmac *rp;
  4868.       struct sbic_softc *sc;
  4869.       
  4870.       sc = (struct sbic_softc *)dp;
  4871.       sc->sc_cregs = rp = ztwomap(0xdd0000);
  4872. +     printf (": sbic ctlr %d\n", sbic_cnt);
  4873. +     sc->sc_no = sbic_cnt++;
  4874.       /*
  4875.        * disable ints and reset bank register
  4876.        */
  4877. *** old-NetBSD/src/sys/arch/amiga/dev/atzsc.c
  4878. --- NetBSD/src/sys/arch/amiga/dev/atzsc.c
  4879. ***************
  4880. *** 121,126 ****
  4881. --- 121,129 ----
  4882.       
  4883.       sc = (struct sbic_softc *)dp;
  4884.       sc->sc_cregs = rp = zap->va;
  4885. +     printf (": sbic ctlr %d", sbic_cnt);
  4886. +     sc->sc_no = sbic_cnt++;
  4887.       /*
  4888.        * disable ints and reset bank register
  4889.        */
  4890. ***************
  4891. *** 158,164 ****
  4892.       sc->sc_sbicp = (sbic_regmap_p) ((int)rp + 0x91);
  4893.       sc->sc_clkfreq = sbic_clock_override ? sbic_clock_override : 77;
  4894.       
  4895. !     printf(": dmamask 0x%x\n", ~sc->sc_dmamask);
  4896.   
  4897.       sc->sc_link.adapter_softc = sc;
  4898.       sc->sc_link.adapter_target = 7;
  4899. --- 161,169 ----
  4900.       sc->sc_sbicp = (sbic_regmap_p) ((int)rp + 0x91);
  4901.       sc->sc_clkfreq = sbic_clock_override ? sbic_clock_override : 77;
  4902.       
  4903. !     printf(" dmamask 0x%x\n", ~sc->sc_dmamask);
  4904. !     sbicreset(sc);
  4905.   
  4906.       sc->sc_link.adapter_softc = sc;
  4907.       sc->sc_link.adapter_target = 7;
  4908. *** old-NetBSD/src/sys/arch/amiga/dev/clock.c
  4909. --- NetBSD/src/sys/arch/amiga/dev/clock.c
  4910. ***************
  4911. *** 50,55 ****
  4912. --- 50,56 ----
  4913.   #include <amiga/amiga/device.h>
  4914.   #include <amiga/amiga/custom.h>
  4915.   #include <amiga/amiga/cia.h>
  4916. + #include <amiga/amiga/isr.h>
  4917.   #include <amiga/dev/rtc.h>
  4918.   #include <amiga/dev/zbusvar.h>
  4919.   
  4920. ***************
  4921. *** 57,62 ****
  4922. --- 58,65 ----
  4923.   #include <sys/PROF.h>
  4924.   #endif
  4925.   
  4926. + extern void hardclock();
  4927.   /* the clocks run at NTSC: 715.909kHz or PAL: 709.379kHz. 
  4928.      We're using a 100 Hz clock. */
  4929.   
  4930. ***************
  4931. *** 65,70 ****
  4932. --- 68,80 ----
  4933.   int eclockfreq;
  4934.   
  4935.   /*
  4936. +  * The INT6 handler copies the clockframe from the stack in here as hardclock
  4937. +  * may be delayed by the IPL-remapping code.  At that time the original stack
  4938. +  * location will no longer be valid.
  4939. +  */
  4940. + struct clockframe hardclock_frame;
  4941. + /*
  4942.    * Machine-dependent clock routines.
  4943.    *
  4944.    * Startrtclock restarts the real-time clock, which provides
  4945. ***************
  4946. *** 137,145 ****
  4947. --- 147,168 ----
  4948.       ciab.tahi = interval >> 8;
  4949.   }
  4950.   
  4951. + int
  4952. + clockintr ()
  4953. + {
  4954. +     /* Is it a timer A interrupt? */
  4955. +     if (ciab.icr & 1) {
  4956. +         hardclock(&hardclock_frame);
  4957. +         return 1;
  4958. +     }
  4959. +     return 0;
  4960. + }
  4961.   void
  4962.   cpu_initclocks()
  4963.   {
  4964. +     static struct isr isr;
  4965.       /*
  4966.        * enable interrupts for timer A
  4967.        */
  4968. ***************
  4969. *** 150,159 ****
  4970.        */
  4971.       ciab.cra = (ciab.cra & 0xc0) | 1;
  4972.     
  4973. !     /*
  4974. !      * and globally enable interrupts for ciab
  4975. !      */
  4976. !     custom.intena = INTF_SETCLR | INTF_EXTER;
  4977.   }
  4978.   
  4979.   setstatclockrate(hz)
  4980. --- 173,182 ----
  4981.        */
  4982.       ciab.cra = (ciab.cra & 0xc0) | 1;
  4983.     
  4984. !     isr.isr_intr = clockintr;
  4985. !     isr.isr_ipl = 6;
  4986. !     isr.isr_mapped_ipl = 4;
  4987. !     add_isr(&isr);
  4988.   }
  4989.   
  4990.   setstatclockrate(hz)
  4991. ***************
  4992. *** 213,219 ****
  4993.   
  4994.       /*
  4995.        * set timer B in "count timer A underflows" mode
  4996. !      * set tiemr A in one-shot mode
  4997.        */
  4998.       ciaa.crb = (ciaa.crb & 0x80) | 0x48;
  4999.       ciaa.cra = (ciaa.cra & 0xc0) | 0x08;
  5000. --- 236,242 ----
  5001.   
  5002.       /*
  5003.        * set timer B in "count timer A underflows" mode
  5004. !      * set timer A in one-shot mode
  5005.        */
  5006.       ciaa.crb = (ciaa.crb & 0x80) | 0x48;
  5007.       ciaa.cra = (ciaa.cra & 0xc0) | 0x08;
  5008. *** old-NetBSD/src/sys/arch/amiga/dev/fd.c
  5009. --- NetBSD/src/sys/arch/amiga/dev/fd.c
  5010. ***************
  5011. *** 481,488 ****
  5012.           return(EBADF);
  5013.   
  5014.       switch (cmd) {
  5015. -     case DIOCSBAD:
  5016. -         return(EINVAL);
  5017.       case DIOCSRETRIES:
  5018.           if (*(int *)addr < 0)
  5019.               return(EINVAL);
  5020. --- 481,486 ----
  5021. *** old-NetBSD/src/sys/arch/amiga/dev/grf_cc.c
  5022. --- NetBSD/src/sys/arch/amiga/dev/grf_cc.c
  5023. ***************
  5024. *** 89,95 ****
  5025.       if (matchname("grfcc", mainbus_name) == 0)
  5026.           return(0);
  5027.       if (amiga_realconfig == 0 || ccconunit != cfp->cf_unit) {
  5028. !         if (grfcc_probe() == 0) 
  5029.               return(0);
  5030.           viewprobe();
  5031.           /*
  5032. --- 89,95 ----
  5033.       if (matchname("grfcc", mainbus_name) == 0)
  5034.           return(0);
  5035.       if (amiga_realconfig == 0 || ccconunit != cfp->cf_unit) {
  5036. !         if (grf_probe() == 0) 
  5037.               return(0);
  5038.           viewprobe();
  5039.           /*
  5040. *** old-NetBSD/src/sys/arch/amiga/dev/grf_rt.c
  5041. --- NetBSD/src/sys/arch/amiga/dev/grf_rt.c
  5042. ***************
  5043. *** 76,84 ****
  5044.    * results from the agreements between MS and me.
  5045.    */
  5046.   
  5047. ! extern unsigned char kernel_font_8x8_width, kernel_font_8x8_height;
  5048. ! extern unsigned char kernel_font_8x8_lo, kernel_font_8x8_hi;
  5049. ! extern unsigned char kernel_font_8x8[];
  5050.   
  5051.   
  5052.   #define MDF_DBL 1      
  5053. --- 76,84 ----
  5054.    * results from the agreements between MS and me.
  5055.    */
  5056.   
  5057. ! extern unsigned char kernel_font_width, kernel_font_height;
  5058. ! extern unsigned char kernel_font_lo, kernel_font_hi;
  5059. ! extern unsigned char kernel_font[];
  5060.   
  5061.   
  5062.   #define MDF_DBL 1      
  5063. ***************
  5064. *** 89,111 ****
  5065.   /* standard-palette definition */
  5066.   
  5067.   unsigned char NCRStdPalette[16*3] = {
  5068. ! /*   R   G   B  */
  5069. !       0,  0,  0,
  5070. !     192,192,192,
  5071. !     128,  0,  0,  
  5072. !       0,128,  0,
  5073. !       0,  0,128,
  5074. !     128,128,  0,  
  5075. !       0,128,128,  
  5076. !     128,  0,128,
  5077. !      64, 64, 64, /* the higher 8 colors have more intensity for  */
  5078. !     255,255,255, /* compatibility with standard attributes       */
  5079. !     255,  0,  0,  
  5080. !       0,255,  0,
  5081. !       0,  0,255,
  5082. !     255,255,  0,  
  5083. !       0,255,255,  
  5084. !     255,  0,255  
  5085.   };
  5086.   
  5087.   
  5088. --- 89,111 ----
  5089.   /* standard-palette definition */
  5090.   
  5091.   unsigned char NCRStdPalette[16*3] = {
  5092. ! /*      R     G     B  */
  5093. !     0x00, 0x00, 0x00,
  5094. !         0x60, 0x60, 0x60,
  5095. !     0x80, 0x00, 0x00,  
  5096. !     0x00, 0x80, 0x00,
  5097. !     0x00, 0x00, 0x80,
  5098. !     0x80, 0x80, 0x00,
  5099. !     0x00, 0x80, 0x80,
  5100. !     0x80, 0x00, 0x80,
  5101. !     0x40, 0x40, 0x40, /* the higher 8 colors have more intensity for  */
  5102. !     0xff, 0xff, 0xff, /* compatibility with standard attributes       */
  5103. !     0xff, 0x00, 0x00,  
  5104. !     0x00, 0xff, 0x00,
  5105. !     0x00, 0x00, 0xff,
  5106. !     0xff, 0xff, 0x00,
  5107. !     0x00, 0xff, 0xff,
  5108. !     0xff, 0x00, 0xff,
  5109.   };
  5110.   
  5111.   
  5112. ***************
  5113. *** 135,180 ****
  5114.   /*                                      FQ     FLG    MW   MH   HBS HSS HSE HBE  HT  VBS  VSS  VSE  VBE   VT  */
  5115.      struct MonDef MON_640_512_60  = { 50000000,  28,  640, 512,   81, 86, 93, 98, 95, 513, 513, 521, 535, 535,
  5116.      /* Depth,           PAL, TX,  TY,    XY,FontX, FontY,    FontData,  FLo,  Fhi */
  5117. !           4, NCRStdPalette, 80,  64,  5120,    8,     8, kernel_font_8x8,   32,  255};      
  5118.   
  5119.    struct MonDef MON_640_480_62_G  = { 50000000,   4,  640, 480,  161,171,184,196,195, 481, 484, 492, 502, 502,
  5120. !           8, NCRStdPalette,640,480,  5120,    8,     8, kernel_font_8x8,   32,  255};      
  5121.   /* Enter higher values here ^   ^ for panning! */
  5122.   
  5123.   /* horizontal 38kHz */
  5124.   
  5125.      struct MonDef MON_768_600_60  = { 75000000,  28,  768, 600,   97, 99,107,120,117, 601, 615, 625, 638, 638,
  5126. !           4, NCRStdPalette, 96,  75,  7200,    8,     8, kernel_font_8x8,   32,  255};      
  5127.   
  5128.   /* horizontal 64kHz */
  5129.   
  5130.      struct MonDef MON_768_600_80  = { 50000000, 24,  768, 600,   97,104,112,122,119, 601, 606, 616, 628, 628,
  5131. !           4, NCRStdPalette, 96,  75,  7200,    8,     8, kernel_font_8x8,   32,  255};      
  5132.   
  5133.      struct MonDef MON_1024_768_80 = { 90000000, 24, 1024, 768,  129,130,141,172,169, 769, 770, 783, 804, 804,
  5134. !           4, NCRStdPalette,128,  96, 12288,    8,     8, kernel_font_8x8,   32,  255};      
  5135.   
  5136.   /*                                     FQ     FLG    MW   MH   HBS HSS HSE HBE  HT  VBS  VSS  VSE  VBE   VT  */
  5137.    struct MonDef MON_1024_768_80_G = { 90000000, 0,  1024, 768,  257,258,280,344,343, 769, 770, 783, 804, 804,
  5138. !           8, NCRStdPalette, 1024, 768, 12288,    8,     8, kernel_font_8x8,   32,  255};      
  5139.   
  5140.      struct MonDef MON_1024_1024_59= { 90000000, 24, 1024,1024,  129,130,141,173,170,1025,1059,1076,1087,1087,
  5141. !           4, NCRStdPalette,128, 128, 16384,    8,     8, kernel_font_8x8,   32,  255};      
  5142.   
  5143.   /* WARNING: THE FOLLOWING MONITOR MODES EXCEED THE 90-MHz LIMIT THE PROCESSOR
  5144.               HAS BEEN SPECIFIED FOR. USE AT YOUR OWN RISK (AND THINK ABOUT
  5145.               MOUNTING SOME COOLING DEVICE AT THE PROCESSOR AND RAMDAC)!     */
  5146.   
  5147.      struct MonDef MON_1280_1024_60= {110000000,  24, 1280,1024,  161,162,176,211,208,1025,1026,1043,1073,1073,
  5148. !           4, NCRStdPalette,160, 128, 20480,    8,     8, kernel_font_8x8,   32,  255};      
  5149.   
  5150.    struct MonDef MON_1280_1024_60_G= {110000000,   0, 1280,1024,  321,322,349,422,421,1025,1026,1043,1073,1073,
  5151. !           8, NCRStdPalette,1280,1024, 20480,    8,     8, kernel_font_8x8,   32,  255};      
  5152.   
  5153.   /* horizontal 75kHz */
  5154.   
  5155.      struct MonDef MON_1280_1024_69= {120000000,  24, 1280,1024,  161,162,175,200,197,1025,1026,1043,1073,1073, 
  5156. !           4, NCRStdPalette,160, 128, 20480,    8,     8, kernel_font_8x8,   32,  255};      
  5157.   
  5158.   #else
  5159.   
  5160. --- 135,180 ----
  5161.   /*                                      FQ     FLG    MW   MH   HBS HSS HSE HBE  HT  VBS  VSS  VSE  VBE   VT  */
  5162.      struct MonDef MON_640_512_60  = { 50000000,  28,  640, 512,   81, 86, 93, 98, 95, 513, 513, 521, 535, 535,
  5163.      /* Depth,           PAL, TX,  TY,    XY,FontX, FontY,    FontData,  FLo,  Fhi */
  5164. !           4, NCRStdPalette, 80,  64,  5120,    8,     8, kernel_font,   32,  255};      
  5165.   
  5166.    struct MonDef MON_640_480_62_G  = { 50000000,   4,  640, 480,  161,171,184,196,195, 481, 484, 492, 502, 502,
  5167. !           8, NCRStdPalette,640,480,  5120,    8,     8, kernel_font,   32,  255};      
  5168.   /* Enter higher values here ^   ^ for panning! */
  5169.   
  5170.   /* horizontal 38kHz */
  5171.   
  5172.      struct MonDef MON_768_600_60  = { 75000000,  28,  768, 600,   97, 99,107,120,117, 601, 615, 625, 638, 638,
  5173. !           4, NCRStdPalette, 96,  75,  7200,    8,     8, kernel_font,   32,  255};      
  5174.   
  5175.   /* horizontal 64kHz */
  5176.   
  5177.      struct MonDef MON_768_600_80  = { 50000000, 24,  768, 600,   97,104,112,122,119, 601, 606, 616, 628, 628,
  5178. !           4, NCRStdPalette, 96,  75,  7200,    8,     8, kernel_font,   32,  255};      
  5179.   
  5180.      struct MonDef MON_1024_768_80 = { 90000000, 24, 1024, 768,  129,130,141,172,169, 769, 770, 783, 804, 804,
  5181. !           4, NCRStdPalette,128,  96, 12288,    8,     8, kernel_font,   32,  255};      
  5182.   
  5183.   /*                                     FQ     FLG    MW   MH   HBS HSS HSE HBE  HT  VBS  VSS  VSE  VBE   VT  */
  5184.    struct MonDef MON_1024_768_80_G = { 90000000, 0,  1024, 768,  257,258,280,344,343, 769, 770, 783, 804, 804,
  5185. !           8, NCRStdPalette, 1024, 768, 12288,    8,     8, kernel_font,   32,  255};      
  5186.   
  5187.      struct MonDef MON_1024_1024_59= { 90000000, 24, 1024,1024,  129,130,141,173,170,1025,1059,1076,1087,1087,
  5188. !           4, NCRStdPalette,128, 128, 16384,    8,     8, kernel_font,   32,  255};      
  5189.   
  5190.   /* WARNING: THE FOLLOWING MONITOR MODES EXCEED THE 90-MHz LIMIT THE PROCESSOR
  5191.               HAS BEEN SPECIFIED FOR. USE AT YOUR OWN RISK (AND THINK ABOUT
  5192.               MOUNTING SOME COOLING DEVICE AT THE PROCESSOR AND RAMDAC)!     */
  5193.   
  5194.      struct MonDef MON_1280_1024_60= {110000000,  24, 1280,1024,  161,162,176,211,208,1025,1026,1043,1073,1073,
  5195. !           4, NCRStdPalette,160, 128, 20480,    8,     8, kernel_font,   32,  255};      
  5196.   
  5197.    struct MonDef MON_1280_1024_60_G= {110000000,   0, 1280,1024,  321,322,349,422,421,1025,1026,1043,1073,1073,
  5198. !           8, NCRStdPalette,1280,1024, 20480,    8,     8, kernel_font,   32,  255};      
  5199.   
  5200.   /* horizontal 75kHz */
  5201.   
  5202.      struct MonDef MON_1280_1024_69= {120000000,  24, 1280,1024,  161,162,175,200,197,1025,1026,1043,1073,1073, 
  5203. !           4, NCRStdPalette,160, 128, 20480,    8,     8, kernel_font,   32,  255};      
  5204.   
  5205.   #else
  5206.   
  5207. ***************
  5208. *** 182,225 ****
  5209.   /* horizontal 31.5 kHz */
  5210.   
  5211.      { 50000000,  28,  640, 512,   81, 86, 93, 98, 95, 513, 513, 521, 535, 535,
  5212. !           4, NCRStdPalette, 80,  64,  5120,    8,     8, kernel_font_8x8,   32,  255},
  5213.   
  5214.   /* horizontal 38kHz */
  5215.   
  5216.      { 75000000,  28,  768, 600,   97, 99,107,120,117, 601, 615, 625, 638, 638,
  5217. !           4, NCRStdPalette, 96,  75,  7200,    8,     8, kernel_font_8x8,   32,  255},
  5218.   
  5219.   /* horizontal 64kHz */
  5220.   
  5221.      { 50000000, 24,  768, 600,   97,104,112,122,119, 601, 606, 616, 628, 628,
  5222. !           4, NCRStdPalette, 96,  75,  7200,    8,     8, kernel_font_8x8,   32,  255},
  5223.      
  5224.      { 90000000, 24, 1024, 768,  129,130,141,172,169, 769, 770, 783, 804, 804,
  5225. !           4, NCRStdPalette,128,  96, 12288,    8,     8, kernel_font_8x8,   32,  255},
  5226.   
  5227.      /* GFX modes */
  5228.   
  5229.   /* horizontal 31.5 kHz */
  5230.   
  5231.      { 50000000,   4,  640, 480,  161,171,184,196,195, 481, 484, 492, 502, 502,
  5232. !           8, NCRStdPalette,640, 480,  5120,    8,     8, kernel_font_8x8,   32,  255},
  5233.   
  5234.   /* horizontal 64kHz */
  5235.   
  5236.      { 90000000, 0,  1024, 768,  257,258,280,344,343, 769, 770, 783, 804, 804,
  5237. !           8, NCRStdPalette, 1024, 768, 12288,    8,     8, kernel_font_8x8,   32,  255},
  5238.   
  5239.   /* WARNING: THE FOLLOWING MONITOR MODES EXCEED THE 90-MHz LIMIT THE PROCESSOR
  5240.               HAS BEEN SPECIFIED FOR. USE AT YOUR OWN RISK (AND THINK ABOUT
  5241.               MOUNTING SOME COOLING DEVICE AT THE PROCESSOR AND RAMDAC)!     */
  5242.   
  5243.      {110000000,   0, 1280,1024,  321,322,349,422,421,1025,1026,1043,1073,1073,
  5244. !           8, NCRStdPalette,1280,1024, 20480,    8,     8, kernel_font_8x8,   32,  255},
  5245.   };
  5246.   
  5247.   static const char *monitor_descr[] = {
  5248.     "80x64 (640x512) 31.5kHz",
  5249.     "96x75 (768x600) 38kHz",
  5250.     "96x75 (768x600) 64kHz",
  5251.     "128x96 (1024x768) 64kHz",
  5252.   
  5253. --- 182,234 ----
  5254.   /* horizontal 31.5 kHz */
  5255.   
  5256.      { 50000000,  28,  640, 512,   81, 86, 93, 98, 95, 513, 513, 521, 535, 535,
  5257. !           4, NCRStdPalette, 80,  64,  5120,    8,     8, kernel_font,   32,  255},
  5258.   
  5259.   /* horizontal 38kHz */
  5260.   
  5261.      { 75000000,  28,  768, 600,   97, 99,107,120,117, 601, 615, 625, 638, 638,
  5262. !           4, NCRStdPalette, 96,  75,  7200,    8,     8, kernel_font,   32,  255},
  5263. ! /* horizontal 50kHz */
  5264. !    { 65000000,  24, 1024, 768,  129,130,140,160,157, 769, 770, 783, 807, 807,
  5265. !           4, NCRStdPalette,128,  96, 12288,    8,     8, kernel_font,   32,  255},
  5266. !    { 90000000,  24, 1264,1008,  159,160,174,219,216,1009,1010,1027,1056,1056,
  5267. !           4, NCRStdPalette,158, 126, 19908,    8,     8, kernel_font,   32,  255},
  5268.   
  5269.   /* horizontal 64kHz */
  5270.   
  5271.      { 50000000, 24,  768, 600,   97,104,112,122,119, 601, 606, 616, 628, 628,
  5272. !           4, NCRStdPalette, 96,  75,  7200,    8,     8, kernel_font,   32,  255},
  5273.      
  5274.      { 90000000, 24, 1024, 768,  129,130,141,172,169, 769, 770, 783, 804, 804,
  5275. !           4, NCRStdPalette,128,  96, 12288,    8,     8, kernel_font,   32,  255},
  5276.   
  5277.      /* GFX modes */
  5278.   
  5279.   /* horizontal 31.5 kHz */
  5280.   
  5281.      { 50000000,   4,  640, 480,  161,171,184,196,195, 481, 484, 492, 502, 502,
  5282. !           8, NCRStdPalette,640, 480,  5120,    8,     8, kernel_font,   32,  255},
  5283.   
  5284.   /* horizontal 64kHz */
  5285.   
  5286.      { 90000000, 0,  1024, 768,  257,258,280,344,343, 769, 770, 783, 804, 804,
  5287. !           8, NCRStdPalette, 1024, 768, 12288,    8,     8, kernel_font,   32,  255},
  5288.   
  5289.   /* WARNING: THE FOLLOWING MONITOR MODES EXCEED THE 90-MHz LIMIT THE PROCESSOR
  5290.               HAS BEEN SPECIFIED FOR. USE AT YOUR OWN RISK (AND THINK ABOUT
  5291.               MOUNTING SOME COOLING DEVICE AT THE PROCESSOR AND RAMDAC)!     */
  5292.   
  5293.      {110000000,   0, 1280,1024,  321,322,349,422,421,1025,1026,1043,1073,1073,
  5294. !           8, NCRStdPalette,1280,1024, 20480,    8,     8, kernel_font,   32,  255},
  5295.   };
  5296.   
  5297.   static const char *monitor_descr[] = {
  5298.     "80x64 (640x512) 31.5kHz",
  5299.     "96x75 (768x600) 38kHz",
  5300. +   "128x96 (1024x768) 50kHz",
  5301. +   "158x126 (1264x1008) 50kHz",
  5302.     "96x75 (768x600) 64kHz",
  5303.     "128x96 (1024x768) 64kHz",
  5304.   
  5305. ***************
  5306. *** 232,238 ****
  5307.   
  5308.   /* patchable */
  5309.   int retina_default_mon = 0;
  5310. ! int retina_default_gfx = 4;
  5311.       
  5312.   #endif
  5313.   
  5314. --- 241,247 ----
  5315.   
  5316.   /* patchable */
  5317.   int retina_default_mon = 0;
  5318. ! int retina_default_gfx = 6;
  5319.       
  5320.   #endif
  5321.   
  5322. *** old-NetBSD/src/sys/arch/amiga/dev/grfabs.c
  5323. --- NetBSD/src/sys/arch/amiga/dev/grfabs.c
  5324. ***************
  5325. *** 45,55 ****
  5326. --- 45,59 ----
  5327.    */
  5328.   
  5329.   /* add your monitor here. */
  5330. + #if NGRFCC > 0
  5331.   monitor_t *cc_init_monitor (void);
  5332. + #endif /* NGRFCC > 0 */
  5333.   
  5334.   /* and here. */
  5335.   monitor_t *(*init_monitor[])(void) = {
  5336. + #if NGRFCC > 0
  5337.       cc_init_monitor, 
  5338. + #endif /* NGRFCC > 0 */
  5339.       NULL
  5340.   };
  5341.   
  5342. ***************
  5343. *** 76,87 ****
  5344.   }
  5345.   
  5346.   /*
  5347. !  * XXX: called from ite console init routine.
  5348.    * Does just what configure will do later but without printing anything.
  5349.    */
  5350.   
  5351.   int
  5352. ! grfcc_probe()
  5353.   {
  5354.       int i = 0;
  5355.       
  5356. --- 80,91 ----
  5357.   }
  5358.   
  5359.   /*
  5360. !  * XXX: called from grf_cc probe routine.
  5361.    * Does just what configure will do later but without printing anything.
  5362.    */
  5363.   
  5364.   int
  5365. ! grf_probe()
  5366.   {
  5367.       int i = 0;
  5368.       
  5369. ***************
  5370. *** 114,119 ****
  5371. --- 118,126 ----
  5372.       dimen_t dim;
  5373.       long dx, dy, ct, dt;
  5374.    
  5375. +     if (monitors == NULL)
  5376. +         return NULL;
  5377.       save = NULL;
  5378.       for (m = monitors->lh_first; m != NULL; m = m->link.le_next) {
  5379.           dim.width = width;
  5380. *** old-NetBSD/src/sys/arch/amiga/dev/grfabs_cc.c
  5381. --- NetBSD/src/sys/arch/amiga/dev/grfabs_cc.c
  5382. ***************
  5383. *** 35,40 ****
  5384. --- 35,43 ----
  5385.    *
  5386.    */
  5387.   
  5388. + #include "grfcc.h"
  5389. + #if NGRFCC > 0
  5390.   #include <sys/param.h>
  5391.   #include <sys/errno.h>
  5392.   #include <sys/cdefs.h>
  5393. ***************
  5394. *** 3113,3115 ****
  5395. --- 3116,3119 ----
  5396.   
  5397.   #endif /* GRF_AGA */
  5398.   #endif /* GRF_PAL */
  5399. + #endif /* NGRFCC > 0 */
  5400. *** old-NetBSD/src/sys/arch/amiga/dev/gtsc.c
  5401. --- NetBSD/src/sys/arch/amiga/dev/gtsc.c
  5402. ***************
  5403. *** 119,124 ****
  5404. --- 119,126 ----
  5405.       gap = auxp;
  5406.       sc = (struct sbic_softc *)dp;
  5407.       sc->sc_cregs = rp = gap->zargs.va;    
  5408. +     printf (": sbic ctlr %d", sbic_cnt);
  5409. +     sc->sc_no = sbic_cnt++;
  5410.   
  5411.       /*
  5412.        * disable ints and reset bank register
  5413. ***************
  5414. *** 147,153 ****
  5415.           sc->sc_dmamask = ~0x01ffffff;
  5416.       else
  5417.           sc->sc_dmamask = ~0x07ffffff;
  5418. !     printf(": dmamask 0x%x", ~sc->sc_dmamask);
  5419.       
  5420.       if ((gap->flags & GVP_NOBANK) == 0)
  5421.           sc->gtsc_bankmask = (~sc->sc_dmamask >> 18) & 0x01c0;
  5422. --- 149,155 ----
  5423.           sc->sc_dmamask = ~0x01ffffff;
  5424.       else
  5425.           sc->sc_dmamask = ~0x07ffffff;
  5426. !     printf(" dmamask 0x%x", ~sc->sc_dmamask);
  5427.       
  5428.       if ((gap->flags & GVP_NOBANK) == 0)
  5429.           sc->gtsc_bankmask = (~sc->sc_dmamask >> 18) & 0x01c0;
  5430. ***************
  5431. *** 385,395 ****
  5432.       int s;
  5433.   
  5434.       s = splbio();
  5435. !     if (sc->sc_dmatimo) {
  5436. !         if (sc->sc_dmatimo > 1)
  5437.               printf("%s: dma timeout #%d\n",
  5438. !                 sc->sc_dev.dv_xname, sc->sc_dmatimo - 1);
  5439. !         sc->sc_dmatimo++;
  5440.       }
  5441.       splx(s);
  5442.       timeout((void *)gtsc_dmatimeout, sc, 30 * hz);
  5443. --- 387,397 ----
  5444.       int s;
  5445.   
  5446.       s = splbio();
  5447. !     if (dev->sc_dmatimo) {
  5448. !         if (dev->sc_dmatimo > 1)
  5449.               printf("%s: dma timeout #%d\n",
  5450. !                 sc->sc_dev.dv_xname, dev->sc_dmatimo - 1);
  5451. !         dev->sc_dmatimo++;
  5452.       }
  5453.       splx(s);
  5454.       timeout((void *)gtsc_dmatimeout, sc, 30 * hz);
  5455. *** old-NetBSD/src/sys/arch/amiga/dev/gtscreg.h
  5456. --- NetBSD/src/sys/arch/amiga/dev/gtscreg.h
  5457. ***************
  5458. *** 34,41 ****
  5459.    *
  5460.    *      @(#)gvp11_dmareg.h
  5461.    */
  5462. ! #ifndef _AMIGA_DEV_AHSCREG_H_
  5463. ! #define _AMIGA_DEV_AHSCREG_H_
  5464.   
  5465.   /*
  5466.    * Hardware layout of the GVP Series II SDMAC. This also contains the
  5467. --- 34,41 ----
  5468.    *
  5469.    *      @(#)gvp11_dmareg.h
  5470.    */
  5471. ! #ifndef _AMIGA_DEV_GTSCREG_H_
  5472. ! #define _AMIGA_DEV_GTSCREG_H_
  5473.   
  5474.   /*
  5475.    * Hardware layout of the GVP Series II SDMAC. This also contains the
  5476. ***************
  5477. *** 72,75 ****
  5478.   #define GVP_CNTR_INTEN          (1<<3)
  5479.   #define GVP_CNTR_DDIR           (1<<4)
  5480.   
  5481. ! #endif /* _AMIGA_DEV_AHSCREG_H_ */
  5482. --- 72,75 ----
  5483.   #define GVP_CNTR_INTEN          (1<<3)
  5484.   #define GVP_CNTR_DDIR           (1<<4)
  5485.   
  5486. ! #endif /* _AMIGA_DEV_GTSCREG_H_ */
  5487. *** old-NetBSD/src/sys/arch/amiga/dev/if_ed.c
  5488. --- /dev/null    Tue Aug 22 20:27:16 1995
  5489. ***************
  5490. *** 1,1238 ****
  5491. - /*    $NetBSD: if_ed.c,v 1.15 1995/08/20 02:52:48 chopps Exp $    */
  5492. - /*
  5493. -  * Device driver for National Semiconductor DS8390/WD83C690 based ethernet
  5494. -  * adapters.
  5495. -  *
  5496. -  * Copyright (c) 1994, 1995 Charles M. Hannum.  All rights reserved.
  5497. -  *
  5498. -  * Copyright (C) 1993, David Greenman.  This software may be used, modified,
  5499. -  * copied, distributed, and sold, in both source and binary form provided that
  5500. -  * the above copyright and these terms are retained.  Under no circumstances is
  5501. -  * the author responsible for the proper functioning of this software, nor does
  5502. -  * the author assume any responsibility for damages incurred with its use.
  5503. -  *
  5504. -  * Currently supports the Hydra Systems ethernet card.
  5505. -  */
  5506. - #include "bpfilter.h"
  5507. - #include <sys/param.h>
  5508. - #include <sys/systm.h>
  5509. - #include <sys/errno.h>
  5510. - #include <sys/ioctl.h>
  5511. - #include <sys/mbuf.h>
  5512. - #include <sys/socket.h>
  5513. - #include <sys/syslog.h>
  5514. - #include <sys/device.h>
  5515. - #include <net/if.h>
  5516. - #include <net/if_dl.h>
  5517. - #include <net/if_types.h>
  5518. - #include <net/netisr.h>
  5519. - #ifdef INET
  5520. - #include <netinet/in.h>
  5521. - #include <netinet/in_systm.h>
  5522. - #include <netinet/in_var.h>
  5523. - #include <netinet/ip.h>
  5524. - #include <netinet/if_ether.h>
  5525. - #endif
  5526. - #ifdef NS
  5527. - #include <netns/ns.h>
  5528. - #include <netns/ns_if.h>
  5529. - #endif
  5530. - #if NBPFILTER > 0
  5531. - #include <net/bpf.h>
  5532. - #include <net/bpfdesc.h>
  5533. - #endif
  5534. - #include <machine/cpu.h>
  5535. - #include <machine/mtpr.h>
  5536. - #include <amiga/amiga/device.h>
  5537. - #include <amiga/amiga/isr.h>
  5538. - #include <amiga/dev/zbusvar.h>
  5539. - #include <dev/ic/dp8390reg.h>
  5540. - #include <amiga/dev/if_edreg.h>
  5541. - #define HYDRA_MANID    2121
  5542. - #define HYDRA_PRODID    1
  5543. - #define ASDG_MANID    1023
  5544. - #define ASDG_PRODID    254
  5545. - /*
  5546. -  * ed_softc: per line info and status
  5547. -  */
  5548. - struct ed_softc {
  5549. -     struct    device sc_dev;
  5550. -     struct    isr sc_isr;
  5551. -     struct    arpcom sc_arpcom;    /* ethernet common */
  5552. -     u_char    volatile *nic_addr;    /* NIC (DS8390) I/O address */
  5553. -     u_char    cr_proto;    /* values always set in CR */
  5554. -     caddr_t    mem_start;    /* NIC memory start address */
  5555. -     caddr_t    mem_end;    /* NIC memory end address */
  5556. -     u_long    mem_size;    /* total NIC memory size */
  5557. -     caddr_t    mem_ring;    /* start of RX ring-buffer (in NIC mem) */
  5558. -     u_char    xmit_busy;    /* transmitter is busy */
  5559. -     u_char    txb_cnt;    /* number of transmit buffers */
  5560. -     u_char    txb_inuse;    /* number of TX buffers currently in-use*/
  5561. -     u_char    txb_new;    /* pointer to where new buffer will be added */
  5562. -     u_char    txb_next_tx;    /* pointer to next buffer ready to xmit */
  5563. -     u_short    txb_len[8];    /* buffered xmit buffer lengths */
  5564. -     u_char    tx_page_start;    /* first page of TX buffer area */
  5565. -     u_char    rec_page_start;    /* first page of RX ring-buffer */
  5566. -     u_char    rec_page_stop;    /* last page of RX ring-buffer */
  5567. -     u_char    next_packet;    /* pointer to next unread RX packet */
  5568. - };
  5569. - int edmatch __P((struct device *, void *, void *));
  5570. - void edattach __P((struct device *, struct device *, void *));
  5571. - int edintr __P((struct ed_softc *));
  5572. - int ed_ioctl __P((struct ifnet *, u_long, caddr_t));
  5573. - void ed_start __P((struct ifnet *));
  5574. - void ed_watchdog __P((/* short */));
  5575. - void ed_reset __P((struct ed_softc *));
  5576. - void ed_init __P((struct ed_softc *));
  5577. - void ed_stop __P((struct ed_softc *));
  5578. - void ed_getmcaf __P((struct arpcom *, u_long *));
  5579. - u_short ed_put __P((struct ed_softc *, struct mbuf *, caddr_t));
  5580. - #define inline    /* XXX for debugging porpoises */
  5581. - void ed_get_packet __P((/* struct ed_softc *, caddr_t, u_short */));
  5582. - static inline void ed_rint __P((struct ed_softc *));
  5583. - static inline void ed_xmit __P((struct ed_softc *));
  5584. - static inline caddr_t ed_ring_copy __P((/* struct ed_softc *, caddr_t, caddr_t,
  5585. -                     u_short */));
  5586. - struct cfdriver edcd = {
  5587. -     NULL, "ed", edmatch, edattach, DV_IFNET, sizeof(struct ed_softc)
  5588. - };
  5589. - #define    ETHER_MIN_LEN    64
  5590. - #define    ETHER_MAX_LEN    1518
  5591. - #define    ETHER_ADDR_LEN    6
  5592. - static inline void
  5593. - NIC_PUT(sc, off, val)
  5594. -     struct ed_softc *sc;
  5595. -     int off;
  5596. -     u_char val;
  5597. - {
  5598. -     sc->nic_addr[off * 2] = val;
  5599. - #ifdef not_def
  5600. -     /*
  5601. -      * This was being used to *slow* access to the bus.  I don't
  5602. -      * believe it is needed but I'll leave it around incase probelms
  5603. -      * pop-up
  5604. -      */
  5605. -     (void)ciaa.pra;
  5606. - #endif
  5607. - }
  5608. - static inline u_char
  5609. - NIC_GET(sc, off)
  5610. -     struct ed_softc *sc;
  5611. -     int off;
  5612. - {
  5613. -     register u_char val;
  5614. -     val = sc->nic_addr[off * 2];
  5615. - #ifdef not_def
  5616. -     /*
  5617. -      * This was being used to *slow* access to the bus.  I don't
  5618. -      * believe it is needed but I'll leave it around incase probelms
  5619. -      * pop-up
  5620. -      */
  5621. -     (void)ciaa.pra;
  5622. - #endif
  5623. -     return (val);
  5624. - }
  5625. - /*
  5626. -  * Memory copy, copies word at time.
  5627. -  */
  5628. - static inline void
  5629. - word_copy(a, b, len)
  5630. -     caddr_t a, b;
  5631. -     int len;
  5632. - {
  5633. -     u_short *x = (u_short *)a,
  5634. -         *y = (u_short *)b;
  5635. -     len >>= 1;
  5636. -     while (len--)
  5637. -         *y++ = *x++;
  5638. - }
  5639. - int
  5640. - edmatch(parent, match, aux)
  5641. -     struct device *parent;
  5642. -     void *match, *aux;
  5643. - {
  5644. -     struct zbus_args *zap = aux;
  5645. -     if (zap->manid == HYDRA_MANID && zap->prodid == HYDRA_PRODID)
  5646. -         return (1);
  5647. -     else if (zap->manid == ASDG_MANID && zap->prodid == ASDG_PRODID)
  5648. -         return (1);
  5649. -     return (0);
  5650. - }
  5651. - void
  5652. - edattach(parent, self, aux)
  5653. -     struct device *parent, *self;
  5654. -     void *aux;
  5655. - {
  5656. -     struct ed_softc *sc = (void *)self;
  5657. -     struct zbus_args *zap = aux;
  5658. -     struct cfdata *cf = sc->sc_dev.dv_cfdata;
  5659. -     struct ifnet *ifp = &sc->sc_arpcom.ac_if;
  5660. -     u_char *prom;
  5661. -     int i;
  5662. -     if (zap->manid == HYDRA_MANID) {
  5663. -         sc->mem_start = zap->va;
  5664. -         sc->nic_addr = sc->mem_start + HYDRA_NIC_BASE;
  5665. -         prom = (u_char *)sc->mem_start + HYDRA_ADDRPROM;
  5666. -     } else {
  5667. -         sc->mem_start = zap->va + 0x8000;
  5668. -         sc->nic_addr = zap->va + ASDG_NIC_BASE;
  5669. -         prom = (u_char *)sc->nic_addr + ASDG_ADDRPROM;
  5670. -     }
  5671. -     sc->cr_proto = ED_CR_RD2;
  5672. -     sc->tx_page_start = 0;
  5673. - #define    memsize    16384
  5674. -     sc->mem_size = memsize;
  5675. -     sc->mem_end = sc->mem_start + memsize;
  5676. -     /*
  5677. -      * Use one xmit buffer if < 16k, two buffers otherwise (if not told
  5678. -      * otherwise).
  5679. -      */
  5680. -     if ((memsize < 16384) || (cf->cf_flags & ED_FLAGS_NO_MULTI_BUFFERING))
  5681. -         sc->txb_cnt = 1;
  5682. -     else
  5683. -         sc->txb_cnt = 2;
  5684. -     sc->rec_page_start = sc->tx_page_start + sc->txb_cnt * ED_TXBUF_SIZE;
  5685. -     sc->rec_page_stop = sc->tx_page_start + (memsize >> ED_PAGE_SHIFT);
  5686. -     sc->mem_ring =
  5687. -         sc->mem_start + ((sc->txb_cnt * ED_TXBUF_SIZE) << ED_PAGE_SHIFT);
  5688. - #undef    memsize
  5689. -     /*
  5690. -      * read the ethernet address from the board
  5691. -      */
  5692. -     for (i = 0; i < ETHER_ADDR_LEN; i++)
  5693. -         sc->sc_arpcom.ac_enaddr[i] = *(prom + 2 * i);
  5694. -     /* Set interface to stopped condition (reset). */
  5695. -     ed_stop(sc);
  5696. -     /* Initialize ifnet structure. */
  5697. -     ifp->if_unit = sc->sc_dev.dv_unit;
  5698. -     ifp->if_name = edcd.cd_name;
  5699. -     ifp->if_start = ed_start;
  5700. -     ifp->if_ioctl = ed_ioctl;
  5701. -     ifp->if_watchdog = ed_watchdog;
  5702. -     ifp->if_flags =
  5703. -         IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST;
  5704. -     /* Attach the interface. */
  5705. -     if_attach(ifp);
  5706. -     ether_ifattach(ifp);
  5707. -     /* Print additional info when attached. */
  5708. -     printf(": address %s\n", ether_sprintf(sc->sc_arpcom.ac_enaddr));
  5709. - #if NBPFILTER > 0
  5710. -     bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header));
  5711. - #endif
  5712. -     sc->sc_isr.isr_intr = edintr;
  5713. -     sc->sc_isr.isr_arg = sc;
  5714. -     sc->sc_isr.isr_ipl = 2;
  5715. -     add_isr(&sc->sc_isr);
  5716. - }
  5717. - /*
  5718. -  * Reset interface.
  5719. -  */
  5720. - void
  5721. - ed_reset(sc)
  5722. -     struct ed_softc *sc;
  5723. - {
  5724. -     int s;
  5725. -     s = splimp();
  5726. -     ed_stop(sc);
  5727. -     ed_init(sc);
  5728. -     splx(s);
  5729. -     log(LOG_ERR, "%s: reset\n", sc->sc_dev.dv_xname);
  5730. - }
  5731. - /*
  5732. -  * Take interface offline.
  5733. -  */
  5734. - void
  5735. - ed_stop(sc)
  5736. -     struct ed_softc *sc;
  5737. - {
  5738. -     int n = 5000;
  5739. -     /* Stop everything on the interface, and select page 0 registers. */
  5740. -     NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STP);
  5741. -     /*
  5742. -      * Wait for interface to enter stopped state, but limit # of checks to
  5743. -      * 'n' (about 5ms).  It shouldn't even take 5us on modern DS8390's, but
  5744. -      * just in case it's an old one.
  5745. -      */
  5746. -     while (((NIC_GET(sc, ED_P0_ISR) & ED_ISR_RST) == 0) && --n);
  5747. - }
  5748. - /*
  5749. -  * Device timeout/watchdog routine.  Entered if the device neglects to generate
  5750. -  * an interrupt after a transmit has been started on it.
  5751. -  */
  5752. - void
  5753. - ed_watchdog(unit)
  5754. -     short unit;
  5755. - {
  5756. -     struct ed_softc *sc = edcd.cd_devs[unit];
  5757. -     log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname);
  5758. -     ++sc->sc_arpcom.ac_if.if_oerrors;
  5759. -     ed_reset(sc);
  5760. - }
  5761. - /*
  5762. -  * Initialize device.
  5763. -  */
  5764. - void
  5765. - ed_init(sc)
  5766. -     struct ed_softc *sc;
  5767. - {
  5768. -     struct ifnet *ifp = &sc->sc_arpcom.ac_if;
  5769. -     int i, s;
  5770. -     u_char command;
  5771. -     u_long mcaf[2];
  5772. -     /*
  5773. -      * Initialize the NIC in the exact order outlined in the NS manual.
  5774. -      * This init procedure is "mandatory"...don't change what or when
  5775. -      * things happen.
  5776. -      */
  5777. -     s = splimp();
  5778. -     /* Reset transmitter flags. */
  5779. -     sc->xmit_busy = 0;
  5780. -     sc->sc_arpcom.ac_if.if_timer = 0;
  5781. -     sc->txb_inuse = 0;
  5782. -     sc->txb_new = 0;
  5783. -     sc->txb_next_tx = 0;
  5784. -     /* Set interface for page 0, remote DMA complete, stopped. */
  5785. -     NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STP);
  5786. -     /*
  5787. -      * Set FIFO threshold to 8, No auto-init Remote DMA, byte
  5788. -      * order=68k, word-wide DMA xfers,
  5789. -      * XXX changed to use 2 word threshhold
  5790. -      */
  5791. -     NIC_PUT(sc, ED_P0_DCR,
  5792. -         ED_DCR_FT0 | ED_DCR_WTS | ED_DCR_LS | ED_DCR_BOS);
  5793. -     /* Clear remote byte count registers. */
  5794. -     NIC_PUT(sc, ED_P0_RBCR0, 0);
  5795. -     NIC_PUT(sc, ED_P0_RBCR1, 0);
  5796. -     /* Tell RCR to do nothing for now. */
  5797. -     NIC_PUT(sc, ED_P0_RCR, ED_RCR_MON);
  5798. -     /* Place NIC in internal loopback mode. */
  5799. -     NIC_PUT(sc, ED_P0_TCR, ED_TCR_LB0);
  5800. -     /* Initialize receive buffer ring. */
  5801. -     NIC_PUT(sc, ED_P0_BNRY, sc->rec_page_start);
  5802. -     NIC_PUT(sc, ED_P0_PSTART, sc->rec_page_start);
  5803. -     NIC_PUT(sc, ED_P0_PSTOP, sc->rec_page_stop);
  5804. -     /*
  5805. -      * Clear all interrupts.  A '1' in each bit position clears the
  5806. -      * corresponding flag.
  5807. -      */
  5808. -     NIC_PUT(sc, ED_P0_ISR, 0xff);
  5809. -     /*
  5810. -      * Enable the following interrupts: receive/transmit complete,
  5811. -      * receive/transmit error, and Receiver OverWrite.
  5812. -      *
  5813. -      * Counter overflow and Remote DMA complete are *not* enabled.
  5814. -      */
  5815. -     NIC_PUT(sc, ED_P0_IMR,
  5816. -         ED_IMR_PRXE | ED_IMR_PTXE | ED_IMR_RXEE | ED_IMR_TXEE |
  5817. -         ED_IMR_OVWE);
  5818. -     /* Program command register for page 1. */
  5819. -     NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_1 | ED_CR_STP);
  5820. -     /* Copy out our station address. */
  5821. -     for (i = 0; i < ETHER_ADDR_LEN; ++i)
  5822. -         NIC_PUT(sc, ED_P1_PAR0 + i, sc->sc_arpcom.ac_enaddr[i]);
  5823. -     /* Set multicast filter on chip. */
  5824. -     ed_getmcaf(&sc->sc_arpcom, mcaf);
  5825. -     for (i = 0; i < 8; i++)
  5826. -         NIC_PUT(sc, ED_P1_MAR0 + i, ((u_char *)mcaf)[i]);
  5827. -     /*
  5828. -      * Set current page pointer to one page after the boundary pointer, as
  5829. -      * recommended in the National manual.
  5830. -      */
  5831. -     sc->next_packet = sc->rec_page_start + 1;
  5832. -     NIC_PUT(sc, ED_P1_CURR, sc->next_packet);
  5833. -     /* Program command register for page 0. */
  5834. -     NIC_PUT(sc, ED_P1_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STP);
  5835. -     i = ED_RCR_AB | ED_RCR_AM;
  5836. -     if (ifp->if_flags & IFF_PROMISC) {
  5837. -         /*
  5838. -          * Set promiscuous mode.  Multicast filter was set earlier so
  5839. -          * that we should receive all multicast packets.
  5840. -          */
  5841. -         i |= ED_RCR_PRO | ED_RCR_AR | ED_RCR_SEP;
  5842. -     }
  5843. -     NIC_PUT(sc, ED_P0_RCR, i);
  5844. -     /* Take interface out of loopback. */
  5845. -     NIC_PUT(sc, ED_P0_TCR, 0);
  5846. -     /* Fire up the interface. */
  5847. -     NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
  5848. -     /* Set 'running' flag, and clear output active flag. */
  5849. -     ifp->if_flags |= IFF_RUNNING;
  5850. -     ifp->if_flags &= ~IFF_OACTIVE;
  5851. -     /* ...and attempt to start output. */
  5852. -     ed_start(ifp);
  5853. -     splx(s);
  5854. - }
  5855. - /*
  5856. -  * This routine actually starts the transmission on the interface.
  5857. -  */
  5858. - static inline void
  5859. - ed_xmit(sc)
  5860. -     struct ed_softc *sc;
  5861. - {
  5862. -     struct ifnet *ifp = &sc->sc_arpcom.ac_if;
  5863. -     u_short len;
  5864. -     len = sc->txb_len[sc->txb_next_tx];
  5865. -     /* Set NIC for page 0 register access. */
  5866. -     NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
  5867. -     /* Set TX buffer start page. */
  5868. -     NIC_PUT(sc, ED_P0_TPSR, sc->tx_page_start +
  5869. -         sc->txb_next_tx * ED_TXBUF_SIZE);
  5870. -     /* Set TX length. */
  5871. -     NIC_PUT(sc, ED_P0_TBCR0, len);
  5872. -     NIC_PUT(sc, ED_P0_TBCR1, len >> 8);
  5873. -     /* Set page 0, remote DMA complete, transmit packet, and *start*. */
  5874. -     NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_TXP | ED_CR_STA);
  5875. -     sc->xmit_busy = 1;
  5876. -     /* Point to next transmit buffer slot and wrap if necessary. */
  5877. -     sc->txb_next_tx++;
  5878. -     if (sc->txb_next_tx == sc->txb_cnt)
  5879. -         sc->txb_next_tx = 0;
  5880. -     /* Set a timer just in case we never hear from the board again. */
  5881. -     ifp->if_timer = 2;
  5882. - }
  5883. - /*
  5884. -  * Start output on interface.
  5885. -  * We make two assumptions here:
  5886. -  *  1) that the current priority is set to splimp _before_ this code
  5887. -  *     is called *and* is returned to the appropriate priority after
  5888. -  *     return
  5889. -  *  2) that the IFF_OACTIVE flag is checked before this code is called
  5890. -  *     (i.e. that the output part of the interface is idle)
  5891. -  */
  5892. - void
  5893. - ed_start(ifp)
  5894. -     struct ifnet *ifp;
  5895. - {
  5896. -     struct ed_softc *sc = edcd.cd_devs[ifp->if_unit];
  5897. -     struct mbuf *m0, *m;
  5898. -     caddr_t buffer;
  5899. -     int len;
  5900. - outloop:
  5901. -     /*
  5902. -      * First, see if there are buffered packets and an idle transmitter -
  5903. -      * should never happen at this point.
  5904. -      */
  5905. -     if (sc->txb_inuse && (sc->xmit_busy == 0)) {
  5906. -         printf("%s: packets buffered, but transmitter idle\n",
  5907. -             sc->sc_dev.dv_xname);
  5908. -         ed_xmit(sc);
  5909. -     }
  5910. -     /* See if there is room to put another packet in the buffer. */
  5911. -     if (sc->txb_inuse == sc->txb_cnt) {
  5912. -         /* No room.  Indicate this to the outside world and exit. */
  5913. -         ifp->if_flags |= IFF_OACTIVE;
  5914. -         return;
  5915. -     }
  5916. -     IF_DEQUEUE(&sc->sc_arpcom.ac_if.if_snd, m);
  5917. -     if (m == 0) {
  5918. -         /*
  5919. -          * We are using the !OACTIVE flag to indicate to the outside
  5920. -          * world that we can accept an additional packet rather than
  5921. -          * that the transmitter is _actually_ active.  Indeed, the
  5922. -          * transmitter may be active, but if we haven't filled all the
  5923. -          * buffers with data then we still want to accept more.
  5924. -          */
  5925. -         ifp->if_flags &= ~IFF_OACTIVE;
  5926. -         return;
  5927. -     }
  5928. -     /* Copy the mbuf chain into the transmit buffer. */
  5929. -     m0 = m;
  5930. -     /* txb_new points to next open buffer slot. */
  5931. -     buffer = sc->mem_start + ((sc->txb_new * ED_TXBUF_SIZE) << ED_PAGE_SHIFT);
  5932. -     len = ed_put(sc, m, buffer);
  5933. -     sc->txb_len[sc->txb_new] = max(len, ETHER_MIN_LEN);
  5934. -     sc->txb_inuse++;
  5935. -     /* Point to next buffer slot and wrap if necessary. */
  5936. -     if (++sc->txb_new == sc->txb_cnt)
  5937. -         sc->txb_new = 0;
  5938. -     if (sc->xmit_busy == 0)
  5939. -         ed_xmit(sc);
  5940. - #if NBPFILTER > 0
  5941. -     /* Tap off here if there is a BPF listener. */
  5942. -     if (sc->sc_arpcom.ac_if.if_bpf)
  5943. -         bpf_mtap(sc->sc_arpcom.ac_if.if_bpf, m0);
  5944. - #endif
  5945. -     m_freem(m0);
  5946. -     /* Loop back to the top to possibly buffer more packets. */
  5947. -     goto outloop;
  5948. - }
  5949. - /*
  5950. -  * Ethernet interface receiver interrupt.
  5951. -  */
  5952. - static inline void
  5953. - ed_rint(sc)
  5954. -     struct ed_softc *sc;
  5955. - {
  5956. -     u_char boundary, current;
  5957. -     u_short len;
  5958. -     u_char nlen;
  5959. -     struct ed_ring packet_hdr;
  5960. -     caddr_t packet_ptr;
  5961. - loop:
  5962. -     /* Set NIC to page 1 registers to get 'current' pointer. */
  5963. -     NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_1 | ED_CR_STA);
  5964. -     /*
  5965. -      * 'sc->next_packet' is the logical beginning of the ring-buffer - i.e.
  5966. -      * it points to where new data has been buffered.  The 'CURR' (current)
  5967. -      * register points to the logical end of the ring-buffer - i.e. it
  5968. -      * points to where additional new data will be added.  We loop here
  5969. -      * until the logical beginning equals the logical end (or in other
  5970. -      * words, until the ring-buffer is empty).
  5971. -      */
  5972. -     current = NIC_GET(sc, ED_P1_CURR);
  5973. -     if (sc->next_packet == current)
  5974. -         return;
  5975. -     /* Set NIC to page 0 registers to update boundary register. */
  5976. -     NIC_PUT(sc, ED_P1_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
  5977. -     do {
  5978. -         /* Get pointer to this buffer's header structure. */
  5979. -         packet_ptr = sc->mem_ring +
  5980. -             ((sc->next_packet - sc->rec_page_start) << ED_PAGE_SHIFT);
  5981. -         /*
  5982. -          * The byte count includes a 4 byte header that was added by
  5983. -          * the NIC.
  5984. -          */
  5985. -         packet_hdr = *(struct ed_ring *)packet_ptr;
  5986. -         packet_hdr.count = ((packet_hdr.count >> 8) & 0xff)
  5987. -              | ((packet_hdr.count & 0xff) << 8);
  5988. -         len = packet_hdr.count;
  5989. -         /*
  5990. -          * Try do deal with old, buggy chips that sometimes duplicate
  5991. -          * the low byte of the length into the high byte.  We do this
  5992. -          * by simply ignoring the high byte of the length and always
  5993. -          * recalculating it.
  5994. -          *
  5995. -          * NOTE: sc->next_packet is pointing at the current packet.
  5996. -          */
  5997. -         if (packet_hdr.next_packet >= sc->next_packet)
  5998. -             nlen = (packet_hdr.next_packet - sc->next_packet);
  5999. -         else
  6000. -             nlen = ((packet_hdr.next_packet - sc->rec_page_start) +
  6001. -                 (sc->rec_page_stop - sc->next_packet));
  6002. -         --nlen;
  6003. -         if ((len & ED_PAGE_MASK) + sizeof(packet_hdr) > ED_PAGE_SIZE)
  6004. -             --nlen;
  6005. -         len = (len & ED_PAGE_MASK) | (nlen << ED_PAGE_SHIFT);
  6006. - #ifdef DIAGNOSTIC
  6007. -         if (len != packet_hdr.count) {
  6008. -             printf("%s: length does not match next packet pointer\n",
  6009. -                 sc->sc_dev.dv_xname);
  6010. -             printf("%s: len %04x nlen %04x start %02x first %02x curr %02x next %02x stop %02x\n",
  6011. -                 sc->sc_dev.dv_xname, packet_hdr.count, len,
  6012. -                 sc->rec_page_start, sc->next_packet, current,
  6013. -                 packet_hdr.next_packet, sc->rec_page_stop);
  6014. -         }
  6015. - #endif
  6016. -         /*
  6017. -          * Be fairly liberal about what we allow as a "reasonable"
  6018. -          * length so that a [crufty] packet will make it to BPF (and
  6019. -          * can thus be analyzed).  Note that all that is really
  6020. -          * important is that we have a length that will fit into one
  6021. -          * mbuf cluster or less; the upper layer protocols can then
  6022. -          * figure out the length from their own length field(s).
  6023. -          *
  6024. -          * MCLBYTES may be less than a valid packet len.  Thus
  6025. -          * we use a constant that is large enough.
  6026. -          */
  6027. -         if (len <= 2048 &&
  6028. -             packet_hdr.next_packet >= sc->rec_page_start &&
  6029. -             packet_hdr.next_packet < sc->rec_page_stop) {
  6030. -             /* Go get packet. */
  6031. -             ed_get_packet(sc, packet_ptr + sizeof(struct ed_ring),
  6032. -                 len - sizeof(struct ed_ring));
  6033. -             ++sc->sc_arpcom.ac_if.if_ipackets;
  6034. -         } else {
  6035. -             /* Really BAD.  The ring pointers are corrupted. */
  6036. -             log(LOG_ERR,
  6037. -                 "%s: NIC memory corrupt - invalid packet length %d\n",
  6038. -                 sc->sc_dev.dv_xname, len);
  6039. -             ++sc->sc_arpcom.ac_if.if_ierrors;
  6040. -             ed_reset(sc);
  6041. -             return;
  6042. -         }
  6043. -         /* Update next packet pointer. */
  6044. -         sc->next_packet = packet_hdr.next_packet;
  6045. -         /*
  6046. -          * Update NIC boundary pointer - being careful to keep it one
  6047. -          * buffer behind (as recommended by NS databook).
  6048. -          */
  6049. -         boundary = sc->next_packet - 1;
  6050. -         if (boundary < sc->rec_page_start)
  6051. -             boundary = sc->rec_page_stop - 1;
  6052. -         NIC_PUT(sc, ED_P0_BNRY, boundary);
  6053. -     } while (sc->next_packet != current);
  6054. -     goto loop;
  6055. - }
  6056. - /* Ethernet interface interrupt processor. */
  6057. - int
  6058. - edintr(sc)
  6059. -     struct ed_softc *sc;
  6060. - {
  6061. -     u_char isr;
  6062. -     /* Set NIC to page 0 registers. */
  6063. -     NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
  6064. -     isr = NIC_GET(sc, ED_P0_ISR);
  6065. -     if (!isr)
  6066. -         return (0);
  6067. -     /* Loop until there are no more new interrupts. */
  6068. -     for (;;) {
  6069. -         /*
  6070. -          * Reset all the bits that we are 'acknowledging' by writing a
  6071. -          * '1' to each bit position that was set.
  6072. -          * (Writing a '1' *clears* the bit.)
  6073. -          */
  6074. -         NIC_PUT(sc, ED_P0_ISR, isr);
  6075. -         /*
  6076. -          * Handle transmitter interrupts.  Handle these first because
  6077. -          * the receiver will reset the board under some conditions.
  6078. -          */
  6079. -         if (isr & (ED_ISR_PTX | ED_ISR_TXE)) {
  6080. -             u_char collisions = NIC_GET(sc, ED_P0_NCR) & 0x0f;
  6081. -             /*
  6082. -              * Check for transmit error.  If a TX completed with an
  6083. -              * error, we end up throwing the packet away.  Really
  6084. -              * the only error that is possible is excessive
  6085. -              * collisions, and in this case it is best to allow the
  6086. -              * automatic mechanisms of TCP to backoff the flow.  Of
  6087. -              * course, with UDP we're screwed, but this is expected
  6088. -              * when a network is heavily loaded.
  6089. -              */
  6090. -             (void) NIC_GET(sc, ED_P0_TSR);
  6091. -             if (isr & ED_ISR_TXE) {
  6092. -                 /*
  6093. -                  * Excessive collisions (16).
  6094. -                  */
  6095. -                 if ((NIC_GET(sc, ED_P0_TSR) & ED_TSR_ABT)
  6096. -                     && (collisions == 0)) {
  6097. -                     /*
  6098. -                      * When collisions total 16, the P0_NCR
  6099. -                      * will indicate 0, and the TSR_ABT is
  6100. -                      * set.
  6101. -                      */
  6102. -                     collisions = 16;
  6103. -                 }
  6104. -                 /* Update output errors counter. */
  6105. -                 ++sc->sc_arpcom.ac_if.if_oerrors;
  6106. -             } else {
  6107. -                 /*
  6108. -                  * Update total number of successfully
  6109. -                  * transmitted packets.
  6110. -                  */
  6111. -                 ++sc->sc_arpcom.ac_if.if_opackets;
  6112. -             }
  6113. -             /* Reset TX busy and output active flags. */
  6114. -             sc->xmit_busy = 0;
  6115. -             sc->sc_arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
  6116. -             /* Clear watchdog timer. */
  6117. -             sc->sc_arpcom.ac_if.if_timer = 0;
  6118. -             /*
  6119. -              * Add in total number of collisions on last
  6120. -              * transmission.
  6121. -              */
  6122. -             sc->sc_arpcom.ac_if.if_collisions += collisions;
  6123. -             /*
  6124. -              * Decrement buffer in-use count if not zero (can only
  6125. -              * be zero if a transmitter interrupt occured while not
  6126. -              * actually transmitting).
  6127. -              * If data is ready to transmit, start it transmitting,
  6128. -              * otherwise defer until after handling receiver.
  6129. -              */
  6130. -             if (sc->txb_inuse && --sc->txb_inuse)
  6131. -                 ed_xmit(sc);
  6132. -         }
  6133. -         /* Handle receiver interrupts. */
  6134. -         if (isr & (ED_ISR_PRX | ED_ISR_RXE | ED_ISR_OVW)) {
  6135. -             /*
  6136. -              * Overwrite warning.  In order to make sure that a
  6137. -              * lockup of the local DMA hasn't occurred, we reset
  6138. -              * and re-init the NIC.  The NSC manual suggests only a
  6139. -              * partial reset/re-init is necessary - but some chips
  6140. -              * seem to want more.  The DMA lockup has been seen
  6141. -              * only with early rev chips - Methinks this bug was
  6142. -              * fixed in later revs.  -DG
  6143. -              */
  6144. -             if (isr & ED_ISR_OVW) {
  6145. -                 ++sc->sc_arpcom.ac_if.if_ierrors;
  6146. - #ifdef DIAGNOSTIC
  6147. -                 log(LOG_WARNING,
  6148. -                     "%s: warning - receiver ring buffer overrun\n",
  6149. -                     sc->sc_dev.dv_xname);
  6150. - #endif
  6151. -                 /* Stop/reset/re-init NIC. */
  6152. -                 ed_reset(sc);
  6153. -             } else {
  6154. -                 /*
  6155. -                  * Receiver Error.  One or more of: CRC error,
  6156. -                  * frame alignment error FIFO overrun, or
  6157. -                  * missed packet.
  6158. -                  */
  6159. -                 if (isr & ED_ISR_RXE) {
  6160. -                     ++sc->sc_arpcom.ac_if.if_ierrors;
  6161. - #ifdef ED_DEBUG
  6162. -                     printf("%s: receive error %x\n",
  6163. -                         sc->sc_dev.dv_xname,
  6164. -                         NIC_GET(sc, ED_P0_RSR));
  6165. - #endif
  6166. -                 }
  6167. -                 /*
  6168. -                  * Go get the packet(s).
  6169. -                  * XXX - Doing this on an error is dubious
  6170. -                  * because there shouldn't be any data to get
  6171. -                  * (we've configured the interface to not
  6172. -                  * accept packets with errors).
  6173. -                  */
  6174. -                 ed_rint(sc);
  6175. -             }
  6176. -         }
  6177. -         /*
  6178. -          * If it looks like the transmitter can take more data, attempt
  6179. -          * to start output on the interface.  This is done after
  6180. -          * handling the receiver to give the receiver priority.
  6181. -          */
  6182. -         if ((sc->sc_arpcom.ac_if.if_flags & IFF_OACTIVE) == 0)
  6183. -             ed_start(&sc->sc_arpcom.ac_if);
  6184. -         /*
  6185. -          * Return NIC CR to standard state: page 0, remote DMA
  6186. -          * complete, start (toggling the TXP bit off, even if was just
  6187. -          * set in the transmit routine, is *okay* - it is 'edge'
  6188. -          * triggered from low to high).
  6189. -          */
  6190. -         NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
  6191. -         /*
  6192. -          * If the Network Talley Counters overflow, read them to reset
  6193. -          * them.  It appears that old 8390's won't clear the ISR flag
  6194. -          * otherwise - resulting in an infinite loop.
  6195. -          */
  6196. -         if (isr & ED_ISR_CNT) {
  6197. -             (void) NIC_GET(sc, ED_P0_CNTR0);
  6198. -             (void) NIC_GET(sc, ED_P0_CNTR1);
  6199. -             (void) NIC_GET(sc, ED_P0_CNTR2);
  6200. -         }
  6201. -         isr = NIC_GET(sc, ED_P0_ISR);
  6202. -         if (!isr)
  6203. -             return (1);
  6204. -     }
  6205. - }
  6206. - /*
  6207. -  * Process an ioctl request.  This code needs some work - it looks pretty ugly.
  6208. -  */
  6209. - int
  6210. - ed_ioctl(ifp, command, data)
  6211. -     register struct ifnet *ifp;
  6212. -     u_long command;
  6213. -     caddr_t data;
  6214. - {
  6215. -     struct ed_softc *sc = edcd.cd_devs[ifp->if_unit];
  6216. -     register struct ifaddr *ifa = (struct ifaddr *)data;
  6217. -     struct ifreq *ifr = (struct ifreq *)data;
  6218. -     int s, error = 0;
  6219. -     s = splimp();
  6220. -     switch (command) {
  6221. -     case SIOCSIFADDR:
  6222. -         ifp->if_flags |= IFF_UP;
  6223. -         switch (ifa->ifa_addr->sa_family) {
  6224. - #ifdef INET
  6225. -         case AF_INET:
  6226. -             ed_init(sc);
  6227. -             arp_ifinit(&sc->sc_arpcom, ifa);
  6228. -             break;
  6229. - #endif
  6230. - #ifdef NS
  6231. -         /* XXX - This code is probably wrong. */
  6232. -         case AF_NS:
  6233. -             {
  6234. -             register struct ns_addr *ina = &IA_SNS(ifa)->sns_addr;
  6235. -             if (ns_nullhost(*ina))
  6236. -                 ina->x_host =
  6237. -                     *(union ns_host *)(sc->sc_arpcom.sc_enaddr);
  6238. -             else
  6239. -                 bcopy(ina->x_host.c_host,
  6240. -                     sc->sc_arpcom.ac_enaddr,
  6241. -                     sizeof(sc->sc_arpcom.ac_enaddr));
  6242. -             /* Set new address. */
  6243. -             ed_init(sc);
  6244. -             break;
  6245. -             }
  6246. - #endif
  6247. -         default:
  6248. -             ed_init(sc);
  6249. -             break;
  6250. -         }
  6251. -         break;
  6252. -     case SIOCSIFFLAGS:
  6253. -         if ((ifp->if_flags & IFF_UP) == 0 &&
  6254. -             (ifp->if_flags & IFF_RUNNING) != 0) {
  6255. -             /*
  6256. -              * If interface is marked down and it is running, then
  6257. -              * stop it.
  6258. -              */
  6259. -             ed_stop(sc);
  6260. -             ifp->if_flags &= ~IFF_RUNNING;
  6261. -         } else if ((ifp->if_flags & IFF_UP) != 0 &&
  6262. -                (ifp->if_flags & IFF_RUNNING) == 0) {
  6263. -             /*
  6264. -              * If interface is marked up and it is stopped, then
  6265. -              * start it.
  6266. -              */
  6267. -             ed_init(sc);
  6268. -         } else {
  6269. -             /*
  6270. -              * Reset the interface to pick up changes in any other
  6271. -              * flags that affect hardware registers.
  6272. -              */
  6273. -             ed_stop(sc);
  6274. -             ed_init(sc);
  6275. -         }
  6276. -         break;
  6277. -     case SIOCADDMULTI:
  6278. -     case SIOCDELMULTI:
  6279. -         /* Update our multicast list. */
  6280. -         error = (command == SIOCADDMULTI) ?
  6281. -             ether_addmulti(ifr, &sc->sc_arpcom) :
  6282. -             ether_delmulti(ifr, &sc->sc_arpcom);
  6283. -         if (error == ENETRESET) {
  6284. -             /*
  6285. -              * Multicast list has changed; set the hardware filter
  6286. -              * accordingly.
  6287. -              */
  6288. -             ed_stop(sc); /* XXX for ds_setmcaf? */
  6289. -             ed_init(sc);
  6290. -             error = 0;
  6291. -         }
  6292. -         break;
  6293. -     default:
  6294. -         error = EINVAL;
  6295. -     }
  6296. -     splx(s);
  6297. -     return (error);
  6298. - }
  6299. - /*
  6300. -  * Retreive packet from shared memory and send to the next level up via
  6301. -  * ether_input().  If there is a BPF listener, give a copy to BPF, too.
  6302. -  */
  6303. - void
  6304. - ed_get_packet(sc, buf, len)
  6305. -     struct ed_softc *sc;
  6306. -     caddr_t buf;
  6307. -     u_short len;
  6308. - {
  6309. -     struct ether_header *eh;
  6310. -     struct mbuf *m, *ed_ring_to_mbuf();
  6311. -     /* round length to word boundry */
  6312. -     len = (len + 1) & ~1;
  6313. -     /* Allocate a header mbuf. */
  6314. -     MGETHDR(m, M_DONTWAIT, MT_DATA);
  6315. -     if (m == 0)
  6316. -         return;
  6317. -     m->m_pkthdr.rcvif = &sc->sc_arpcom.ac_if;
  6318. -     m->m_pkthdr.len = len;
  6319. -     m->m_len = 0;
  6320. -     /* The following silliness is to make NFS happy. */
  6321. - #define EROUND    ((sizeof(struct ether_header) + 3) & ~3)
  6322. - #define EOFF    (EROUND - sizeof(struct ether_header))
  6323. -     /*
  6324. -      * The following assumes there is room for the ether header in the
  6325. -      * header mbuf.
  6326. -      */
  6327. -     m->m_data += EOFF;
  6328. -     eh = mtod(m, struct ether_header *);
  6329. -     word_copy(buf, mtod(m, caddr_t), sizeof(struct ether_header));
  6330. -     buf += sizeof(struct ether_header);
  6331. -     m->m_len += sizeof(struct ether_header);
  6332. -     len -= sizeof(struct ether_header);
  6333. -     /* Pull packet off interface. */
  6334. -     if (ed_ring_to_mbuf(sc, buf, m, len) == 0) {
  6335. -         m_freem(m);
  6336. -         return;
  6337. -     }
  6338. - #if NBPFILTER > 0
  6339. -     /*
  6340. -      * Check if there's a BPF listener on this interface.  If so, hand off
  6341. -      * the raw packet to bpf.
  6342. -      */
  6343. -     if (sc->sc_arpcom.ac_if.if_bpf) {
  6344. -         bpf_mtap(sc->sc_arpcom.ac_if.if_bpf, m);
  6345. -         /*
  6346. -          * Note that the interface cannot be in promiscuous mode if
  6347. -          * there are no BPF listeners.  And if we are in promiscuous
  6348. -          * mode, we have to check if this packet is really ours.
  6349. -          */
  6350. -         if ((sc->sc_arpcom.ac_if.if_flags & IFF_PROMISC) &&
  6351. -             (eh->ether_dhost[0] & 1) == 0 && /* !mcast and !bcast */
  6352. -             bcmp(eh->ether_dhost, sc->sc_arpcom.ac_enaddr,
  6353. -                 sizeof(eh->ether_dhost)) != 0) {
  6354. -             m_freem(m);
  6355. -             return;
  6356. -         }
  6357. -     }
  6358. - #endif
  6359. -     /* Fix up data start offset in mbuf to point past ether header. */
  6360. -     m_adj(m, sizeof(struct ether_header));
  6361. -     ether_input(&sc->sc_arpcom.ac_if, eh, m);
  6362. - }
  6363. - /*
  6364. -  * Supporting routines.
  6365. -  */
  6366. - /*
  6367. -  * Given a source and destination address, copy 'amount' of a packet from the
  6368. -  * ring buffer into a linear destination buffer.  Takes into account ring-wrap.
  6369. -  */
  6370. - static inline caddr_t
  6371. - ed_ring_copy(sc, src, dst, amount)
  6372. -     struct ed_softc *sc;
  6373. -     caddr_t src, dst;
  6374. -     u_short amount;
  6375. - {
  6376. -     u_short tmp_amount;
  6377. -     /* Does copy wrap to lower addr in ring buffer? */
  6378. -     if (src + amount > sc->mem_end) {
  6379. -         tmp_amount = sc->mem_end - src;
  6380. -         /* Copy amount up to end of NIC memory. */
  6381. -         word_copy(src, dst, tmp_amount);
  6382. -         amount -= tmp_amount;
  6383. -         src = sc->mem_ring;
  6384. -         dst += tmp_amount;
  6385. -     }
  6386. -     word_copy(src, dst, amount);
  6387. -     return (src + amount);
  6388. - }
  6389. - /*
  6390. -  * Copy data from receive buffer to end of mbuf chain allocate additional mbufs
  6391. -  * as needed.  Return pointer to last mbuf in chain.
  6392. -  * sc = ed info (softc)
  6393. -  * src = pointer in ed ring buffer
  6394. -  * dst = pointer to last mbuf in mbuf chain to copy to
  6395. -  * amount = amount of data to copy
  6396. -  */
  6397. - struct mbuf *
  6398. - ed_ring_to_mbuf(sc, src, dst, total_len)
  6399. -     struct ed_softc *sc;
  6400. -     caddr_t src;
  6401. -     struct mbuf *dst;
  6402. -     u_short total_len;
  6403. - {
  6404. -     register struct mbuf *m = dst;
  6405. -     /* Round the length to a word boundary. */
  6406. -     /* total_len = (total_len + 1) & ~1; */
  6407. -     while (total_len) {
  6408. -         register u_short amount = min(total_len, M_TRAILINGSPACE(m));
  6409. -         if (amount == 0) {
  6410. -             /*
  6411. -              * No more data in this mbuf; alloc another.
  6412. -              *
  6413. -              * If there is enough data for an mbuf cluster, attempt
  6414. -              * to allocate one of those, otherwise, a regular mbuf
  6415. -              * will do.
  6416. -              * Note that a regular mbuf is always required, even if
  6417. -              * we get a cluster - getting a cluster does not
  6418. -              * allocate any mbufs, and one is needed to assign the
  6419. -              * cluster to.  The mbuf that has a cluster extension
  6420. -              * can not be used to contain data - only the cluster
  6421. -              * can contain data.
  6422. -              */
  6423. -             dst = m;
  6424. -             MGET(m, M_DONTWAIT, MT_DATA);
  6425. -             if (m == 0)
  6426. -                 return (0);
  6427. -             if (total_len >= MINCLSIZE)
  6428. -                 MCLGET(m, M_DONTWAIT);
  6429. -             m->m_len = 0;
  6430. -             dst->m_next = m;
  6431. -             amount = min(total_len, M_TRAILINGSPACE(m));
  6432. -         }
  6433. -         src = ed_ring_copy(sc, src, mtod(m, caddr_t) + m->m_len,
  6434. -             amount);
  6435. -         m->m_len += amount;
  6436. -         total_len -= amount;
  6437. -     }
  6438. -     return (m);
  6439. - }
  6440. - /*
  6441. -  * Compute the multicast address filter from the list of multicast addresses we
  6442. -  * need to listen to.
  6443. -  */
  6444. - void
  6445. - ed_getmcaf(ac, af)
  6446. -     struct arpcom *ac;
  6447. -     u_long *af;
  6448. - {
  6449. -     struct ifnet *ifp = &ac->ac_if;
  6450. -     struct ether_multi *enm;
  6451. -     register u_char *cp, c;
  6452. -     register u_long crc;
  6453. -     register int i, len;
  6454. -     struct ether_multistep step;
  6455. -     /*
  6456. -      * Set up multicast address filter by passing all multicast addresses
  6457. -      * through a crc generator, and then using the high order 6 bits as an
  6458. -      * index into the 64 bit logical address filter.  The high order bit
  6459. -      * selects the word, while the rest of the bits select the bit within
  6460. -      * the word.
  6461. -      */
  6462. -     if (ifp->if_flags & IFF_PROMISC) {
  6463. -         ifp->if_flags |= IFF_ALLMULTI;
  6464. -         af[0] = af[1] = 0xffffffff;
  6465. -         return;
  6466. -     }
  6467. -     af[0] = af[1] = 0;
  6468. -     ETHER_FIRST_MULTI(step, ac, enm);
  6469. -     while (enm != NULL) {
  6470. -         if (bcmp(enm->enm_addrlo, enm->enm_addrhi,
  6471. -             sizeof(enm->enm_addrlo)) != 0) {
  6472. -             /*
  6473. -              * We must listen to a range of multicast addresses.
  6474. -              * For now, just accept all multicasts, rather than
  6475. -              * trying to set only those filter bits needed to match
  6476. -              * the range.  (At this time, the only use of address
  6477. -              * ranges is for IP multicast routing, for which the
  6478. -              * range is big enough to require all bits set.)
  6479. -              */
  6480. -             ifp->if_flags |= IFF_ALLMULTI;
  6481. -             af[0] = af[1] = 0xffffffff;
  6482. -             return;
  6483. -         }
  6484. -         cp = enm->enm_addrlo;
  6485. -         crc = 0xffffffff;
  6486. -         for (len = sizeof(enm->enm_addrlo); --len >= 0;) {
  6487. -             c = *cp++;
  6488. -             for (i = 8; --i >= 0;) {
  6489. -                 if (((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01)) {
  6490. -                     crc <<= 1;
  6491. -                     crc ^= 0x04c11db6 | 1;
  6492. -                 } else
  6493. -                     crc <<= 1;
  6494. -                 c >>= 1;
  6495. -             }
  6496. -         }
  6497. -         /* Just want the 6 most significant bits. */
  6498. -         crc >>= 26;
  6499. -         /* Turn on the corresponding bit in the filter. */
  6500. -         af[crc >> 5] |= 1 << ((crc & 0x1f) ^ 0);
  6501. -         ETHER_NEXT_MULTI(step, enm);
  6502. -     }
  6503. -     ifp->if_flags &= ~IFF_ALLMULTI;
  6504. - }
  6505. - /*
  6506. -  * Copy packet from mbuf to the board memory
  6507. -  *
  6508. -  * Currently uses an extra buffer/extra memory copy,
  6509. -  * unless the whole packet fits in one mbuf.
  6510. -  *
  6511. -  */
  6512. - u_short
  6513. - ed_put(sc, m, buf)
  6514. -     struct ed_softc *sc;
  6515. -     struct mbuf *m;
  6516. -     caddr_t buf;
  6517. - {
  6518. -     u_char *data, savebyte[2];
  6519. -     int len, wantbyte;
  6520. -     u_short totlen;
  6521. -     totlen = wantbyte = 0;
  6522. -     for (; m != 0; m = m->m_next) {
  6523. -         data = mtod(m, u_char *);
  6524. -         len = m->m_len;
  6525. -         totlen += len;
  6526. -         if (len > 0) {
  6527. -             /* Finish the last word. */
  6528. -             if (wantbyte) {
  6529. -                 savebyte[1] = *data;
  6530. -                 word_copy(savebyte, buf, 2);
  6531. -                 buf += 2;
  6532. -                 data++;
  6533. -                 len--;
  6534. -                 wantbyte = 0;
  6535. -             }
  6536. -             /* Output contiguous words. */
  6537. -             if (len > 1) {
  6538. -                 word_copy(data, buf, len);
  6539. -                 buf += len & ~1;
  6540. -                 data += len & ~1;
  6541. -                 len &= 1;
  6542. -             }
  6543. -             /* Save last byte, if necessary. */
  6544. -             if (len == 1) {
  6545. -                 savebyte[0] = *data;
  6546. -                 wantbyte = 1;
  6547. -             }
  6548. -         }
  6549. -     }
  6550. -     if (wantbyte) {
  6551. -         savebyte[1] = 0;
  6552. -         word_copy(savebyte, buf, 2);
  6553. -         buf += 2;
  6554. -     }
  6555. -     return (totlen);
  6556. - }
  6557. --- 0 ----
  6558. *** old-NetBSD/src/sys/arch/amiga/dev/if_edreg.h
  6559. --- /dev/null    Tue Aug 22 20:27:16 1995
  6560. ***************
  6561. *** 1,43 ****
  6562. - /*    $NetBSD: if_edreg.h,v 1.4 1995/05/08 02:40:54 chopps Exp $    */
  6563. - /*
  6564. -  * Vendor types
  6565. -  */
  6566. - #define    ED_VENDOR_HYDRA        0x03    /* Hydra Systems */
  6567. - /*
  6568. -  * Compile-time config flags
  6569. -  */
  6570. - /*
  6571. -  * This sets the default for enabling/disablng the tranceiver.
  6572. -  */
  6573. - #define ED_FLAGS_DISABLE_TRANCEIVER    0x0001
  6574. - /*
  6575. -  * This forces the board to be used in 8/16-bit mode even if it autoconfigs
  6576. -  * differently.
  6577. -  */
  6578. - #define ED_FLAGS_FORCE_8BIT_MODE    0x0002
  6579. - #define ED_FLAGS_FORCE_16BIT_MODE    0x0004
  6580. - /*
  6581. -  * This disables the use of double transmit buffers.
  6582. -  */
  6583. - #define ED_FLAGS_NO_MULTI_BUFFERING    0x0008
  6584. - /*
  6585. -  * This forces all operations with the NIC memory to use Programmed I/O (i.e.
  6586. -  * not via shared memory).
  6587. -  */
  6588. - #define ED_FLAGS_FORCE_PIO        0x0010
  6589. - /*
  6590. -  *        Definitions for Hydra Systems boards
  6591. -  */
  6592. - #define    HYDRA_ADDRPROM    0xffc0
  6593. - #define    HYDRA_NIC_BASE    0xffe1
  6594. - /*
  6595. -  *        Definitions for ASDG LANRover boards
  6596. -  */
  6597. - #define ASDG_ADDRPROM    0xff
  6598. - #define ASDG_NIC_BASE    0x1
  6599. --- 0 ----
  6600. *** old-NetBSD/src/sys/arch/amiga/dev/if_le.c
  6601. --- /dev/null    Tue Aug 22 20:27:16 1995
  6602. ***************
  6603. *** 1,957 ****
  6604. - /*    $NetBSD: if_le.c,v 1.14 1995/07/02 00:16:06 mycroft Exp $    */
  6605. - /*
  6606. -  * Copyright (c) 1982, 1990 The Regents of the University of California.
  6607. -  * All rights reserved.
  6608. -  *
  6609. -  * Redistribution and use in source and binary forms, with or without
  6610. -  * modification, are permitted provided that the following conditions
  6611. -  * are met:
  6612. -  * 1. Redistributions of source code must retain the above copyright
  6613. -  *    notice, this list of conditions and the following disclaimer.
  6614. -  * 2. Redistributions in binary form must reproduce the above copyright
  6615. -  *    notice, this list of conditions and the following disclaimer in the
  6616. -  *    documentation and/or other materials provided with the distribution.
  6617. -  * 3. All advertising materials mentioning features or use of this software
  6618. -  *    must display the following acknowledgement:
  6619. -  *    This product includes software developed by the University of
  6620. -  *    California, Berkeley and its contributors.
  6621. -  * 4. Neither the name of the University nor the names of its contributors
  6622. -  *    may be used to endorse or promote products derived from this software
  6623. -  *    without specific prior written permission.
  6624. -  *
  6625. -  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  6626. -  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  6627. -  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  6628. -  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  6629. -  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  6630. -  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  6631. -  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  6632. -  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  6633. -  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  6634. -  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  6635. -  * SUCH DAMAGE.
  6636. -  *
  6637. -  *    @(#)if_le.c    7.6 (Berkeley) 5/8/91
  6638. -  */
  6639. - #include "le.h"
  6640. - #if NLE > 0
  6641. - #include "bpfilter.h"
  6642. - /*
  6643. -  * AMD 7990 LANCE
  6644. -  *
  6645. -  * This driver will generate and accept tailer encapsulated packets even
  6646. -  * though it buys us nothing.  The motivation was to avoid incompatibilities
  6647. -  * with VAXen, SUNs, and others that handle and benefit from them.
  6648. -  * This reasoning is dubious.
  6649. -  */
  6650. - #include <sys/param.h>
  6651. - #include <sys/systm.h>
  6652. - #include <sys/mbuf.h>
  6653. - #include <sys/buf.h>
  6654. - #include <sys/protosw.h>
  6655. - #include <sys/socket.h>
  6656. - #include <sys/syslog.h>
  6657. - #include <sys/ioctl.h>
  6658. - #include <sys/errno.h>
  6659. - #include <sys/device.h>
  6660. - #include <net/if.h>
  6661. - #include <net/netisr.h>
  6662. - #include <net/route.h>
  6663. - #ifdef INET
  6664. - #include <netinet/in.h>
  6665. - #include <netinet/in_systm.h>
  6666. - #include <netinet/in_var.h>
  6667. - #include <netinet/ip.h>
  6668. - #include <netinet/if_ether.h>
  6669. - #endif
  6670. - #ifdef NS
  6671. - #include <netns/ns.h>
  6672. - #include <netns/ns_if.h>
  6673. - #endif
  6674. - #include <machine/cpu.h>
  6675. - #include <machine/mtpr.h>
  6676. - #include <amiga/amiga/device.h>
  6677. - #include <amiga/amiga/isr.h>
  6678. - #include <amiga/dev/zbusvar.h>
  6679. - #include <amiga/dev/if_lereg.h>
  6680. - /*
  6681. -  * Ethernet software status per interface.
  6682. -  *
  6683. -  * Each interface is referenced by a network interface structure,
  6684. -  * le_if, which the routing code uses to locate the interface.
  6685. -  * This structure contains the output queue for the interface, its address, ...
  6686. -  */
  6687. - struct    le_softc {
  6688. -     struct    isr sc_isr;
  6689. -     struct    arpcom sc_ac;    /* common Ethernet structures */
  6690. - #define    sc_if    sc_ac.ac_if    /* network-visible interface */
  6691. - #define    sc_addr    sc_ac.ac_enaddr    /* hardware Ethernet address */
  6692. -     void    *sc_base;    /* base address of board */
  6693. -     struct    lereg1 *sc_r1;    /* LANCE registers */
  6694. -     struct    lereg2 *sc_r2;    /* dual-port RAM */
  6695. -     int    sc_rmd;        /* predicted next rmd to process */
  6696. -     int    sc_tmd;        /* next tmd to use */
  6697. -     int    sc_no_td;    /* number of tmds in use */
  6698. -     int    sc_runt;
  6699. -     int    sc_jab;
  6700. -     int    sc_merr;
  6701. -     int    sc_babl;
  6702. -     int    sc_cerr;
  6703. -     int    sc_miss;
  6704. -     int    sc_xint;
  6705. -     int    sc_xown;
  6706. -     int    sc_uflo;
  6707. -     int    sc_rxlen;
  6708. -     int    sc_rxoff;
  6709. -     int    sc_txoff;
  6710. -     int    sc_busy;
  6711. -     short    sc_iflags;
  6712. - #if NBPFILTER > 0
  6713. -     caddr_t sc_bpf;
  6714. - #endif
  6715. - } le_softc[NLE];
  6716. - #if NBPFILTER > 0
  6717. - #include <net/bpf.h>
  6718. - #include <net/bpfdesc.h>
  6719. - #endif
  6720. - /* offsets for:       ID,   REGS,    MEM */
  6721. - int    lestd[] = { 0, 0x4000, 0x8000 };
  6722. - /* console error messages */
  6723. - int    ledebug = 0;
  6724. - int leioctl __P((struct ifnet *, u_long, caddr_t));
  6725. - int leintr __P((struct le_softc *));
  6726. - void lestart __P((struct ifnet *));
  6727. - void leinit __P((int));
  6728. - struct    mbuf *leget();
  6729. - extern    struct ifnet loif;
  6730. - void leattach __P((struct device *, struct device *, void *));
  6731. - int lematch __P((struct device *, struct cfdata *, void *args));
  6732. - struct cfdriver lecd = {
  6733. -     NULL, "le", (cfmatch_t)lematch, leattach, DV_IFNET,
  6734. -     sizeof(struct le_softc), NULL, 0};
  6735. - int
  6736. - lematch(pdp, cfp, auxp)
  6737. -     struct device *pdp;
  6738. -     struct cfdata *cfp;
  6739. -     void *auxp;
  6740. - {
  6741. -     struct zbus_args *zap;
  6742. -     zap = (struct zbus_args *)auxp;
  6743. -     /* Commodore ethernet card */
  6744. -     if ( zap->manid == 514 && zap->prodid == 112)
  6745. -         return(1);
  6746. -     /* Ameristar ethernet card */
  6747. -     if ( zap->manid == 1053 && zap->prodid == 1)
  6748. -         return(1);
  6749. -     return (0);
  6750. - }
  6751. - /*
  6752. -  * Interface exists: make available by filling in network interface
  6753. -  * record.  System will initialize the interface when it is ready
  6754. -  * to accept packets.
  6755. -  */
  6756. - void
  6757. - leattach(pdp, dp, auxp)
  6758. -     struct device *pdp, *dp;
  6759. -     void *auxp;
  6760. - {
  6761. -     register struct lereg0 *ler0;
  6762. -     register struct lereg2 *ler2;
  6763. -     struct zbus_args *zap;
  6764. -     struct lereg2 *lemem = (struct lereg2 *) 0x8000;
  6765. -     struct le_softc *le = &le_softc[dp->dv_unit];
  6766. -     struct ifnet *ifp = &le->sc_if;
  6767. -     char *cp;
  6768. -     int i;
  6769. -     unsigned long ser;
  6770. -     int s = splhigh ();
  6771. -     zap =(struct zbus_args *)auxp;
  6772. -     /*
  6773. -      * Make config msgs look nicer.
  6774. -      */
  6775. -     printf("\n");
  6776. -     ler0 = le->sc_base = zap->va;
  6777. -     le->sc_r1 = (struct lereg1 *)(lestd[1] + (int)zap->va);
  6778. -     ler2 = le->sc_r2 = (struct lereg2 *)(lestd[2] + (int)zap->va);
  6779. -     /*
  6780. -      * Manufacturer decides the 3 first bytes, i.e. ethernet vendor ID.
  6781. -      */
  6782. -     if ( zap->manid == 514 && zap->prodid == 112) {
  6783. -         /* Commodore 2065 */
  6784. -         le->sc_addr[0] = 0x00;
  6785. -         le->sc_addr[1] = 0x80;
  6786. -         le->sc_addr[2] = 0x10;
  6787. -     }
  6788. -     if ( zap->manid == 1053 && zap->prodid == 1) {
  6789. -         le->sc_addr[0] = 0x00;
  6790. -         le->sc_addr[1] = 0x00;
  6791. -         le->sc_addr[2] = 0x9f;
  6792. -     }
  6793. -     /*
  6794. -      * Serial number for board is used as host ID.
  6795. -      */
  6796. -     ser = (unsigned long) zap->serno;
  6797. -     le->sc_addr[3] = (ser >> 16) & 0xff;
  6798. -     le->sc_addr[4] = (ser >>  8) & 0xff;
  6799. -     le->sc_addr[5] = (ser      ) & 0xff;
  6800. - #ifdef LE_USE_16K
  6801. -     printf("le%d: hardware address %s 16K\n",
  6802. - #else
  6803. -     printf("le%d: hardware address %s 32K\n",
  6804. - #endif
  6805. -     dp->dv_unit, ether_sprintf(le->sc_addr));
  6806. -     /*
  6807. -      * Setup for transmit/receive
  6808. -      */
  6809. -     ler2->ler2_mode = LE_MODE;
  6810. -     ler2->ler2_padr[0] = le->sc_addr[1];
  6811. -     ler2->ler2_padr[1] = le->sc_addr[0];
  6812. -     ler2->ler2_padr[2] = le->sc_addr[3];
  6813. -     ler2->ler2_padr[3] = le->sc_addr[2];
  6814. -     ler2->ler2_padr[4] = le->sc_addr[5];
  6815. -     ler2->ler2_padr[5] = le->sc_addr[4];
  6816. -     ler2->ler2_ladrf0 = 0;
  6817. -     ler2->ler2_ladrf1 = 0;
  6818. -     ler2->ler2_rlen = LE_RLEN;
  6819. -     ler2->ler2_rdra = (int)lemem->ler2_rmd;
  6820. -     ler2->ler2_tlen = LE_TLEN;
  6821. -     ler2->ler2_tdra = (int)lemem->ler2_tmd;
  6822. -     splx (s);
  6823. -     ifp->if_unit = dp->dv_unit;
  6824. -     ifp->if_name = "le";
  6825. -     ifp->if_mtu = ETHERMTU;
  6826. -     ifp->if_ioctl = leioctl;
  6827. -     ifp->if_output = ether_output;
  6828. -     ifp->if_start = lestart;
  6829. -     ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX;
  6830. - #if NBPFILTER > 0
  6831. -     bpfattach(&le->sc_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header));
  6832. - #endif
  6833. -     if_attach(ifp);
  6834. -     ether_ifattach(ifp);
  6835. -     le->sc_isr.isr_intr = leintr;
  6836. -     le->sc_isr.isr_arg = le;
  6837. -     le->sc_isr.isr_ipl = 2;
  6838. -     add_isr (&le->sc_isr);
  6839. -     return;
  6840. - }
  6841. - ledrinit(ler2)
  6842. -     register struct lereg2 *ler2;
  6843. - {
  6844. -     register struct lereg2 *lemem = (struct lereg2 *) 0x8000;
  6845. -     register int i;
  6846. -     for (i = 0; i < LERBUF; i++) {
  6847. -         ler2->ler2_rmd[i].rmd0 = (int)lemem->ler2_rbuf[i];
  6848. -         ler2->ler2_rmd[i].rmd1 = LE_OWN;
  6849. -         ler2->ler2_rmd[i].rmd2 = -LEMTU;
  6850. -         ler2->ler2_rmd[i].rmd3 = 0;
  6851. -     }
  6852. -     for (i = 0; i < LETBUF; i++) {
  6853. -         ler2->ler2_tmd[i].tmd0 = (int)lemem->ler2_tbuf[i];
  6854. -         ler2->ler2_tmd[i].tmd1 = 0;
  6855. -         ler2->ler2_tmd[i].tmd2 = 0;
  6856. -         ler2->ler2_tmd[i].tmd3 = 0;
  6857. -     }
  6858. - }
  6859. - void
  6860. - lereset(unit)
  6861. -     register int unit;
  6862. - {
  6863. -     register struct le_softc *le = &le_softc[unit];
  6864. -     register struct lereg1 *ler1 = le->sc_r1;
  6865. -     /*
  6866. -      * This structure is referenced from the CARDS/LANCE point of
  6867. -      * view, thus the 0x8000 address which is the buffer RAM area of
  6868. -      * the Commodore and Ameristar cards. This pointer is manipulated
  6869. -      * with the LANCE's view of memory and NOT the Amiga's. FYI.
  6870. -      */
  6871. -     register struct lereg2 *lemem = (struct lereg2 *) 0x8000;
  6872. -     register int timo = 100000;
  6873. -     register int stat;
  6874. - #ifdef lint
  6875. -     stat = unit;
  6876. - #endif
  6877. - #if NBPFILTER > 0
  6878. -     if (le->sc_if.if_flags & IFF_PROMISC)
  6879. -         /* set the promiscuous bit */
  6880. -         le->sc_r2->ler2_mode = LE_MODE|0x8000;
  6881. -     else
  6882. -         le->sc_r2->ler2_mode = LE_MODE;
  6883. - #endif
  6884. -      ler1->ler1_rap =  LE_CSR0;
  6885. -      ler1->ler1_rdp =  LE_STOP;
  6886. -      ledrinit(le->sc_r2);
  6887. -      le->sc_rmd = le->sc_tmd = le->sc_no_td = 0;
  6888. -      ler1->ler1_rap =  LE_CSR1;
  6889. -      ler1->ler1_rdp =  (int)&lemem->ler2_mode;
  6890. -      ler1->ler1_rap =  LE_CSR2;
  6891. -      ler1->ler1_rdp =  0;
  6892. -      ler1->ler1_rap =  LE_CSR0;
  6893. -      ler1->ler1_rdp =  LE_INIT;
  6894. -     do {
  6895. -         if (--timo == 0) {
  6896. -             printf("le%d: init timeout, stat = 0x%x\n",
  6897. -                    unit, stat);
  6898. -             break;
  6899. -         }
  6900. -          stat =  ler1->ler1_rdp;
  6901. -     } while ((stat & LE_IDON) == 0);
  6902. -      ler1->ler1_rdp =  LE_STOP;
  6903. -      ler1->ler1_rap =  LE_CSR3;
  6904. -      ler1->ler1_rdp =  LE_BSWP;
  6905. -      ler1->ler1_rap =  LE_CSR0;
  6906. -      ler1->ler1_rdp =  LE_STRT | LE_INEA;
  6907. -      le->sc_if.if_flags &= ~IFF_OACTIVE;
  6908. -     return;
  6909. - }
  6910. - /*
  6911. -  * Initialization of interface
  6912. -  */
  6913. - void
  6914. - leinit(unit)
  6915. -     int unit;
  6916. - {
  6917. -     struct le_softc *le = &le_softc[unit];
  6918. -     register struct ifnet *ifp = &le->sc_if;
  6919. -     int s;
  6920. -     if ((ifp->if_flags & IFF_RUNNING) == 0) {
  6921. -         s = splimp();
  6922. -         ifp->if_flags |= IFF_RUNNING;
  6923. -         lereset(unit);
  6924. -             (void) lestart(ifp);
  6925. -         splx(s);
  6926. -     }
  6927. -     return;
  6928. - }
  6929. - #define LENEXTTMP \
  6930. -     if (++bix == LETBUF) bix = 0, tmd = le->sc_r2->ler2_tmd; else ++tmd
  6931. - /*
  6932. -  * Start output on interface.  Get another datagram to send
  6933. -  * off of the interface queue, and copy it to the interface
  6934. -  * before starting the output.
  6935. -  */
  6936. - void
  6937. - lestart(ifp)
  6938. -     struct ifnet *ifp;
  6939. - {
  6940. -     register struct le_softc *le = &le_softc[ifp->if_unit];
  6941. -     register int bix;
  6942. -     register struct letmd *tmd;
  6943. -     register struct mbuf *m;
  6944. -     int len;
  6945. -     if ((le->sc_if.if_flags & IFF_RUNNING) == 0)
  6946. -         return;
  6947. -     bix = le->sc_tmd;
  6948. -     tmd = &le->sc_r2->ler2_tmd[bix];
  6949. -     for (;;) {
  6950. -         if (le->sc_no_td >= LETBUF) {
  6951. -             le->sc_if.if_flags |= IFF_OACTIVE;
  6952. -             break;
  6953. -         }
  6954. -         IF_DEQUEUE(&le->sc_if.if_snd, m);
  6955. -         if (m == 0)
  6956. -             break;
  6957. -         ++le->sc_no_td;
  6958. -         len = leput(le->sc_r2->ler2_tbuf[bix], m);
  6959. - #if NBPFILTER > 0
  6960. -         /*
  6961. -          * If bpf is listening on this interface, let it
  6962. -          * see the packet before we commit it to the wire.
  6963. -          */
  6964. -         if (le->sc_bpf)
  6965. -                     bpf_tap(le->sc_bpf, le->sc_r2->ler2_tbuf[bix], len);
  6966. - #endif
  6967. -         tmd->tmd3 = 0;
  6968. -         tmd->tmd2 = -len;
  6969. -         tmd->tmd1 = LE_OWN | LE_STP | LE_ENP;
  6970. -         LENEXTTMP;
  6971. -     }
  6972. -     le->sc_tmd = bix;
  6973. - }
  6974. - int
  6975. - leintr(le)
  6976. -     struct le_softc *le;
  6977. - {
  6978. - #if 0
  6979. -     register struct le_softc *le = &le_softc[unit];
  6980. - #else
  6981. -     int unit = le->sc_if.if_unit;
  6982. - #endif
  6983. -     register struct lereg1 *ler1;
  6984. -     register int stat;
  6985. -     /* if not even initialized, don't do anything further.. */
  6986. -     if (! le->sc_base)
  6987. -       return 0;
  6988. -     ler1 = le->sc_r1;
  6989. -     stat =  ler1->ler1_rdp;
  6990. -     if (! (stat & LE_INTR))
  6991. -       return 0;
  6992. -     if (stat & LE_SERR) {
  6993. -         leerror(unit, stat);
  6994. -         if (stat & LE_MERR) {
  6995. -             le->sc_merr++;
  6996. -             lereset(unit);
  6997. -             return(1);
  6998. -         }
  6999. -         if (stat & LE_BABL)
  7000. -             le->sc_babl++;
  7001. -         if (stat & LE_CERR)
  7002. -             le->sc_cerr++;
  7003. -         if (stat & LE_MISS)
  7004. -             le->sc_miss++;
  7005. -          ler1->ler1_rdp =  LE_BABL|LE_CERR|LE_MISS|LE_INEA;
  7006. -     }
  7007. -     if ((stat & LE_RXON) == 0) {
  7008. -         le->sc_rxoff++;
  7009. -         lereset(unit);
  7010. -         return(1);
  7011. -     }
  7012. -     if ((stat & LE_TXON) == 0) {
  7013. -         le->sc_txoff++;
  7014. -         lereset(unit);
  7015. -         return(1);
  7016. -     }
  7017. -     if (stat & LE_RINT) {
  7018. -         /* interrupt is cleared in lerint */
  7019. -         lerint(unit);
  7020. -     }
  7021. -     if (stat & LE_TINT) {
  7022. -          ler1->ler1_rdp =  LE_TINT|LE_INEA;
  7023. -         lexint(unit);
  7024. -     }
  7025. -     return(1);
  7026. - }
  7027. - /*
  7028. -  * Ethernet interface transmitter interrupt.
  7029. -  * Start another output if more data to send.
  7030. -  */
  7031. - lexint(unit)
  7032. -     register int unit;
  7033. - {
  7034. -     register struct le_softc *le = &le_softc[unit];
  7035. -     register int bix = (le->sc_tmd - le->sc_no_td + LETBUF) % LETBUF;
  7036. -     register struct letmd *tmd = &le->sc_r2->ler2_tmd[bix];
  7037. -     if ((le->sc_if.if_flags & IFF_OACTIVE) == 0) {
  7038. -         le->sc_xint++;
  7039. -         return;
  7040. -     }
  7041. -     if (tmd->tmd1 & LE_OWN) {
  7042. - printf("le%d: extra xint\n", unit);
  7043. -         le->sc_xown++;
  7044. -         return;
  7045. -     }
  7046. -     le->sc_if.if_flags &= ~IFF_OACTIVE;
  7047. -     do {
  7048. -         if (le->sc_no_td <= 0)
  7049. -             break;
  7050. -         --le->sc_no_td;
  7051. -         if (tmd->tmd1 & LE_ERR) {
  7052. - err:
  7053. - printf("le%d: xint error\n", unit);
  7054. -             lexerror(unit);
  7055. -             le->sc_if.if_oerrors++;
  7056. -             if (tmd->tmd3 & (LE_TBUFF|LE_UFLO)) {
  7057. -                 le->sc_uflo++;
  7058. -                 lereset(unit);
  7059. -                 return;
  7060. -             }
  7061. -             else if (tmd->tmd3 & LE_LCOL)
  7062. -                 le->sc_if.if_collisions++;
  7063. -             else if (tmd->tmd3 & LE_RTRY)
  7064. -                 le->sc_if.if_collisions += 16;
  7065. -         }
  7066. -         else if (tmd->tmd3 & LE_TBUFF)
  7067. -             /* XXX documentation says BUFF not included in ERR */
  7068. -             goto err;
  7069. -         else if (tmd->tmd1 & LE_ONE)
  7070. -             le->sc_if.if_collisions++;
  7071. -         else if (tmd->tmd1 & LE_MORE)
  7072. -             /* what is the real number? */
  7073. -             le->sc_if.if_collisions += 2;
  7074. -         else
  7075. -             le->sc_if.if_opackets++;
  7076. -         LENEXTTMP;
  7077. -     } while ((tmd->tmd1 & LE_OWN) == 0);
  7078. -     (void) lestart(&le->sc_if);
  7079. - }
  7080. - #define    LENEXTRMP \
  7081. -     if (++bix == LERBUF) bix = 0, rmd = le->sc_r2->ler2_rmd; else ++rmd
  7082. - /*
  7083. -  * Ethernet interface receiver interrupt.
  7084. -  * If input error just drop packet.
  7085. -  * Decapsulate packet based on type and pass to type specific
  7086. -  * higher-level input routine.
  7087. -  */
  7088. - lerint(unit)
  7089. -     int unit;
  7090. - {
  7091. -     register struct le_softc *le = &le_softc[unit];
  7092. -     register int bix = le->sc_rmd;
  7093. -     register struct lermd *rmd = &le->sc_r2->ler2_rmd[bix];
  7094. -     /*
  7095. -      * Out of sync with hardware, should never happen?
  7096. -      */
  7097. -     if (rmd->rmd1 & LE_OWN) {
  7098. -          le->sc_r1->ler1_rdp =  LE_RINT|LE_INEA;
  7099. -         return;
  7100. -     }
  7101. -     /*
  7102. -      * Process all buffers with valid data
  7103. -      */
  7104. -     while ((rmd->rmd1 & LE_OWN) == 0) {
  7105. -         int len = rmd->rmd3;
  7106. -         /* Clear interrupt to avoid race condition */
  7107. -          le->sc_r1->ler1_rdp =  LE_RINT|LE_INEA;
  7108. -         if (rmd->rmd1 & LE_ERR) {
  7109. -             le->sc_rmd = bix;
  7110. -             lererror(unit, "bad packet");
  7111. -             le->sc_if.if_ierrors++;
  7112. -         } else if ((rmd->rmd1 & (LE_STP|LE_ENP)) != (LE_STP|LE_ENP)) {
  7113. -             /*
  7114. -              * Find the end of the packet so we can see how long
  7115. -              * it was.  We still throw it away.
  7116. -              */
  7117. -             do {
  7118. -                     le->sc_r1->ler1_rdp = LE_RINT|LE_INEA;
  7119. -                 rmd->rmd3 = 0;
  7120. -                 rmd->rmd1 = LE_OWN;
  7121. -                 LENEXTRMP;
  7122. -             } while (!(rmd->rmd1 & (LE_OWN|LE_ERR|LE_STP|LE_ENP)));
  7123. -             le->sc_rmd = bix;
  7124. -             lererror(unit, "chained buffer");
  7125. -             le->sc_rxlen++;
  7126. -             /*
  7127. -              * If search terminated without successful completion
  7128. -              * we reset the hardware (conservative).
  7129. -              */
  7130. -             if ((rmd->rmd1 & (LE_OWN|LE_ERR|LE_STP|LE_ENP)) != LE_ENP) {
  7131. -                 lereset(unit);
  7132. -                 return;
  7133. -             }
  7134. -         } else
  7135. -             leread(unit, le->sc_r2->ler2_rbuf[bix], len);
  7136. -         rmd->rmd3 = 0;
  7137. -         rmd->rmd1 = LE_OWN;
  7138. -         LENEXTRMP;
  7139. -     }
  7140. -     le->sc_rmd = bix;
  7141. - }
  7142. - leread(unit, buf, len)
  7143. -     int unit;
  7144. -     char *buf;
  7145. -     int len;
  7146. - {
  7147. -     register struct le_softc *le = &le_softc[unit];
  7148. -     register struct ether_header *et;
  7149. -         struct mbuf *m;
  7150. -     int off, resid;
  7151. -     le->sc_if.if_ipackets++;
  7152. -     et = (struct ether_header *)buf;
  7153. -     et->ether_type = ntohs((u_short)et->ether_type);
  7154. -     /* adjust input length to account for header and CRC */
  7155. -     len = len - sizeof(struct ether_header) - 4;
  7156. - #define    ledataaddr(et, off, type)    ((type)(((caddr_t)((et)+1)+(off))))
  7157. -     if (et->ether_type >= ETHERTYPE_TRAIL &&
  7158. -         et->ether_type < ETHERTYPE_TRAIL+ETHERTYPE_NTRAILER) {
  7159. -         off = (et->ether_type - ETHERTYPE_TRAIL) * 512;
  7160. -         if (off >= ETHERMTU)
  7161. -             return;        /* sanity */
  7162. -         et->ether_type = ntohs(*ledataaddr(et, off, u_short *));
  7163. -         resid = ntohs(*(ledataaddr(et, off+2, u_short *)));
  7164. -         if (off + resid > len)
  7165. -             return;        /* sanity */
  7166. -         len = off + resid;
  7167. -     } else
  7168. -         off = 0;
  7169. -     if (len <= 0) {
  7170. -         if (ledebug)
  7171. -             log(LOG_WARNING,
  7172. -                 "le%d: ierror(runt packet): from %s: len=%d\n",
  7173. -                 unit, ether_sprintf(et->ether_shost), len);
  7174. -         le->sc_runt++;
  7175. -         le->sc_if.if_ierrors++;
  7176. -         return;
  7177. -     }
  7178. - #if NBPFILTER > 0
  7179. -     /*
  7180. -      * Check if there's a bpf filter listening on this interface.
  7181. -      * If so, hand off the raw packet to bpf, which must deal with
  7182. -      * trailers in its own way.
  7183. -      */
  7184. -     if (le->sc_bpf) {
  7185. -         bpf_tap(le->sc_bpf, buf, len + sizeof(struct ether_header));
  7186. -         /*
  7187. -          * Note that the interface cannot be in promiscuous mode if
  7188. -          * there are no bpf listeners.  And if we are in promiscuous
  7189. -          * mode, we have to check if this packet is really ours.
  7190. -          *
  7191. -          * XXX This test does not support multicasts.
  7192. -          */
  7193. -         if ((le->sc_if.if_flags & IFF_PROMISC)
  7194. -             && bcmp(et->ether_dhost, le->sc_addr, 
  7195. -                 sizeof(et->ether_dhost)) != 0
  7196. -             && bcmp(et->ether_dhost, etherbroadcastaddr, 
  7197. -                 sizeof(et->ether_dhost)) != 0)
  7198. -             return;
  7199. -     }
  7200. - #endif
  7201. -     /*
  7202. -      * Pull packet off interface.  Off is nonzero if packet
  7203. -      * has trailing header; leget will then force this header
  7204. -      * information to be at the front, but we still have to drop
  7205. -      * the type and length which are at the front of any trailer data.
  7206. -      */
  7207. -     m = leget(buf, len, off, &le->sc_if);
  7208. -     if (m == 0)
  7209. -         return;
  7210. -     ether_input(&le->sc_if, et, m);
  7211. - }
  7212. - /*
  7213. -  * Routine to copy from mbuf chain to transmit
  7214. -  * buffer in board local memory.
  7215. -  */
  7216. - leput(lebuf, m)
  7217. -     register char *lebuf;
  7218. -     register struct mbuf *m;
  7219. - {
  7220. -     register struct mbuf *mp;
  7221. -     register int len, tlen = 0;
  7222. -     for (mp = m; mp; mp = mp->m_next) {
  7223. -         len = mp->m_len;
  7224. -         if (len == 0)
  7225. -             continue;
  7226. -         tlen += len;
  7227. -         bcopy(mtod(mp, char *), lebuf, len);
  7228. -         lebuf += len;
  7229. -     }
  7230. -     m_freem(m);
  7231. -     if (tlen < LEMINSIZE) {
  7232. -         bzero(lebuf, LEMINSIZE - tlen);
  7233. -         tlen = LEMINSIZE;
  7234. -     }
  7235. -     return(tlen);
  7236. - }
  7237. - /*
  7238. -  * Routine to copy from board local memory into mbufs.
  7239. -  */
  7240. - struct mbuf *
  7241. - leget(lebuf, totlen, off0, ifp)
  7242. -     char *lebuf;
  7243. -     int totlen, off0;
  7244. -     struct ifnet *ifp;
  7245. - {
  7246. -     register struct mbuf *m;
  7247. -     struct mbuf *top = 0, **mp = ⊤
  7248. -     register int off = off0, len;
  7249. -     register char *cp;
  7250. -     char *epkt;
  7251. -     lebuf += sizeof (struct ether_header);
  7252. -     cp = lebuf;
  7253. -     epkt = cp + totlen;
  7254. -     if (off) {
  7255. -         cp += off + 2 * sizeof(u_short);
  7256. -         totlen -= 2 * sizeof(u_short);
  7257. -     }
  7258. -     MGETHDR(m, M_DONTWAIT, MT_DATA);
  7259. -     if (m == 0)
  7260. -         return (0);
  7261. -     m->m_pkthdr.rcvif = ifp;
  7262. -     m->m_pkthdr.len = totlen;
  7263. -     m->m_len = MHLEN;
  7264. -     while (totlen > 0) {
  7265. -         if (top) {
  7266. -             MGET(m, M_DONTWAIT, MT_DATA);
  7267. -             if (m == 0) {
  7268. -                 m_freem(top);
  7269. -                 return (0);
  7270. -             }
  7271. -             m->m_len = MLEN;
  7272. -         }
  7273. -         len = min(totlen, epkt - cp);
  7274. -         if (len >= MINCLSIZE) {
  7275. -             MCLGET(m, M_DONTWAIT);
  7276. -             if (m->m_flags & M_EXT)
  7277. -                 m->m_len = len = min(len, MCLBYTES);
  7278. -             else
  7279. -                 len = m->m_len;
  7280. -         } else {
  7281. -             /*
  7282. -              * Place initial small packet/header at end of mbuf.
  7283. -              */
  7284. -             if (len < m->m_len) {
  7285. -                 if (top == 0 && len + max_linkhdr <= m->m_len)
  7286. -                     m->m_data += max_linkhdr;
  7287. -                 m->m_len = len;
  7288. -             } else
  7289. -                 len = m->m_len;
  7290. -         }
  7291. -         bcopy(cp, mtod(m, caddr_t), (unsigned)len);
  7292. -         cp += len;
  7293. -         *mp = m;
  7294. -         mp = &m->m_next;
  7295. -         totlen -= len;
  7296. -         if (cp == epkt)
  7297. -             cp = lebuf;
  7298. -     }
  7299. -     return (top);
  7300. - }
  7301. - /*
  7302. -  * Process an ioctl request.
  7303. -  */
  7304. - int
  7305. - leioctl(ifp, cmd, data)
  7306. -     register struct ifnet *ifp;
  7307. -     u_long cmd;
  7308. -     caddr_t data;
  7309. - {
  7310. -     register struct ifaddr *ifa = (struct ifaddr *)data;
  7311. -     struct le_softc *le = &le_softc[ifp->if_unit];
  7312. -     struct lereg1 *ler1 = le->sc_r1;
  7313. -     int s = splimp(), error = 0;
  7314. -     switch (cmd) {
  7315. -     case SIOCSIFADDR:
  7316. -         ifp->if_flags |= IFF_UP;
  7317. -         switch (ifa->ifa_addr->sa_family) {
  7318. - #ifdef INET
  7319. -         case AF_INET:
  7320. -             leinit(ifp->if_unit);
  7321. -             arp_ifinit(&le->sc_ac, ifa);
  7322. -             break;
  7323. - #endif
  7324. - #ifdef NS
  7325. -         case AF_NS:
  7326. -             {
  7327. -             register struct ns_addr *ina = &(IA_SNS(ifa)->sns_addr);
  7328. -             if (ns_nullhost(*ina))
  7329. -                 ina->x_host = *(union ns_host *)(le->sc_addr);
  7330. -             else {
  7331. -                 /* 
  7332. -                  * The manual says we can't change the address 
  7333. -                  * while the receiver is armed,
  7334. -                  * so reset everything
  7335. -                  */
  7336. -                 ifp->if_flags &= ~IFF_RUNNING; 
  7337. -                 bcopy((caddr_t)ina->x_host.c_host,
  7338. -                     (caddr_t)le->sc_addr, sizeof(le->sc_addr));
  7339. -             }
  7340. -             leinit(ifp->if_unit); /* does le_setaddr() */
  7341. -             break;
  7342. -             }
  7343. - #endif
  7344. -         default:
  7345. -             leinit(ifp->if_unit);
  7346. -             break;
  7347. -         }
  7348. -         break;
  7349. -     case SIOCSIFFLAGS:
  7350. -         if ((ifp->if_flags & IFF_UP) == 0 &&
  7351. -             ifp->if_flags & IFF_RUNNING) {
  7352. -              ler1->ler1_rdp =  LE_STOP;
  7353. -             ifp->if_flags &= ~IFF_RUNNING;
  7354. -         } else if (ifp->if_flags & IFF_UP && (ifp->if_flags & IFF_RUNNING) == 0)
  7355. -             leinit(ifp->if_unit);
  7356. -         /*
  7357. -          * If the state of the promiscuous bit changes, the interface
  7358. -          * must be reset to effect the change.
  7359. -          */
  7360. -         if (((ifp->if_flags ^ le->sc_iflags) & IFF_PROMISC) && (ifp->if_flags & IFF_RUNNING)) {
  7361. -             le->sc_iflags = ifp->if_flags;
  7362. -             lereset(ifp->if_unit);
  7363. -             lestart(ifp);
  7364. -         }
  7365. -         break;
  7366. -     default:
  7367. -         error = EINVAL;
  7368. -     }
  7369. -     splx(s);
  7370. -     return (error);
  7371. - }
  7372. - leerror(unit, stat)
  7373. -     int unit;
  7374. -     int stat;
  7375. - {
  7376. -     if (!ledebug)
  7377. -         return;
  7378. -     /*
  7379. -      * Not all transceivers implement heartbeat
  7380. -      * so we only log CERR once.
  7381. -      */
  7382. -     if ((stat & LE_CERR) && le_softc[unit].sc_cerr)
  7383. -         return;
  7384. -     log(LOG_WARNING,
  7385. -         "le%d: error: stat=%b\n", unit,
  7386. -         stat,
  7387. -         "\20\20ERR\17BABL\16CERR\15MISS\14MERR\13RINT\12TINT\11IDON\10INTR\07INEA\06RXON\05TXON\04TDMD\03STOP\02STRT\01INIT");
  7388. - }
  7389. - lererror(unit, msg)
  7390. -     int unit;
  7391. -     char *msg;
  7392. - {
  7393. -     register struct le_softc *le = &le_softc[unit];
  7394. -     register struct lermd *rmd;
  7395. -     int len;
  7396. -     if (!ledebug)
  7397. -         return;
  7398. -     rmd = &le->sc_r2->ler2_rmd[le->sc_rmd];
  7399. -     len = rmd->rmd3;
  7400. -     log(LOG_WARNING,
  7401. -         "le%d: ierror(%s): from %s: buf=%d, len=%d, rmd1=%b\n",
  7402. -         unit, msg,
  7403. -         len > 11 ? ether_sprintf(&le->sc_r2->ler2_rbuf[le->sc_rmd][6]) : "unknown",
  7404. -         le->sc_rmd, len,
  7405. -         rmd->rmd1,
  7406. -         "\20\20OWN\17ERR\16FRAM\15OFLO\14CRC\13RBUF\12STP\11ENP");
  7407. - }
  7408. - lexerror(unit)
  7409. -     int unit;
  7410. - {
  7411. -     register struct le_softc *le = &le_softc[unit];
  7412. -     int bix;
  7413. -     register struct letmd *tmd;
  7414. -     int len;
  7415. -     if (!ledebug)
  7416. -         return;
  7417. -     bix = (le->sc_tmd - le->sc_no_td + LETBUF) % LETBUF;
  7418. -     tmd = &le->sc_r2->ler2_tmd[bix];
  7419. -     len = -tmd->tmd2;
  7420. -     log(LOG_WARNING,
  7421. -         "le%d: oerror: to %s: buf=%d, len=%d, tmd1=%b, tmd3=%b\n",
  7422. -         unit,
  7423. -         len > 5 ? ether_sprintf(&le->sc_r2->ler2_tbuf[0][0]) : "unknown",
  7424. -         0, len,
  7425. -         tmd->tmd1,
  7426. -         "\20\20OWN\17ERR\16RES\15MORE\14ONE\13DEF\12STP\11ENP",
  7427. -         tmd->tmd3,
  7428. -         "\20\20BUFF\17UFLO\16RES\15LCOL\14LCAR\13RTRY");
  7429. - }
  7430. - #endif
  7431. --- 0 ----
  7432. *** old-NetBSD/src/sys/arch/amiga/dev/if_lereg.h
  7433. --- /dev/null    Tue Aug 22 20:27:16 1995
  7434. ***************
  7435. *** 1,175 ****
  7436. - /*    $NetBSD: if_lereg.h,v 1.5 1994/12/28 09:25:30 chopps Exp $    */
  7437. - /*
  7438. -  * Copyright (c) 1982, 1990 The Regents of the University of California.
  7439. -  * All rights reserved.
  7440. -  *
  7441. -  * Redistribution and use in source and binary forms, with or without
  7442. -  * modification, are permitted provided that the following conditions
  7443. -  * are met:
  7444. -  * 1. Redistributions of source code must retain the above copyright
  7445. -  *    notice, this list of conditions and the following disclaimer.
  7446. -  * 2. Redistributions in binary form must reproduce the above copyright
  7447. -  *    notice, this list of conditions and the following disclaimer in the
  7448. -  *    documentation and/or other materials provided with the distribution.
  7449. -  * 3. All advertising materials mentioning features or use of this software
  7450. -  *    must display the following acknowledgement:
  7451. -  *    This product includes software developed by the University of
  7452. -  *    California, Berkeley and its contributors.
  7453. -  * 4. Neither the name of the University nor the names of its contributors
  7454. -  *    may be used to endorse or promote products derived from this software
  7455. -  *    without specific prior written permission.
  7456. -  *
  7457. -  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  7458. -  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  7459. -  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  7460. -  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  7461. -  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  7462. -  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  7463. -  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  7464. -  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  7465. -  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  7466. -  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  7467. -  * SUCH DAMAGE.
  7468. -  *
  7469. -  *    @(#)if_lereg.h    7.1 (Berkeley) 5/8/90
  7470. -  */
  7471. - #define    LEID        21
  7472. - #define    LEMTU        1518
  7473. - #define    LEMINSIZE    60    /* should be 64 if mode DTCR is set */
  7474. - /* HP seems to have 16K RAM on board, A2065/Ameristar come with 32K.
  7475. -    First try to get a working driver with the HP values, and later 
  7476. -    try and see whether 32K works too. */
  7477. - #define LE_USE_32K
  7478. - #ifdef LE_USE_16K
  7479. - #define    LERBUF        8
  7480. - #define    LERBUFLOG2    3
  7481. - #define    LETBUF        4
  7482. - #define    LETBUFLOG2    2
  7483. - #else /* 32K */
  7484. - #define LERBUF        16
  7485. - #define LERBUFLOG2    4
  7486. - #define LETBUF        4
  7487. - #define LETBUFLOG2    2
  7488. - #endif
  7489. - #define    LE_RLEN        (LERBUFLOG2 << 13)
  7490. - #define    LE_TLEN        (LETBUFLOG2 << 13)
  7491. - #define vu_char        volatile u_char
  7492. - /*
  7493. -  * LANCE registers.
  7494. -  */
  7495. - #if 0
  7496. - /* doesn't exist on amiga, there's autoconfig registers in this area  */
  7497. - struct lereg0 {
  7498. -     u_char    ler0_pad0;
  7499. -     vu_char    ler0_id;    /* ID */
  7500. -     u_char    ler0_pad1;
  7501. -     vu_char    ler0_status;    /* interrupt enable/status */
  7502. - };
  7503. - #endif
  7504. - struct lereg1 {
  7505. -     u_short    ler1_rdp;    /* data port */
  7506. -     u_short    ler1_rap;    /* register select port */
  7507. - };
  7508. - /*
  7509. -  * Overlayed on 16K dual-port RAM.
  7510. -  * Current size is 13,758 bytes with 8 x 1518 receive buffers and
  7511. -  * 1 x 1518 transmit buffer.
  7512. -  */
  7513. - struct lereg2 {
  7514. -     /* init block */
  7515. -     u_short    ler2_mode;        /* +0x0000 */
  7516. -     u_char    ler2_padr[6];        /* +0x0002 */
  7517. -     u_long    ler2_ladrf0;        /* +0x0008 */
  7518. -     u_long    ler2_ladrf1;        /* +0x000C */
  7519. -     u_short    ler2_rdra;        /* +0x0010 */
  7520. -     u_short    ler2_rlen;        /* +0x0012 */
  7521. -     u_short    ler2_tdra;        /* +0x0014 */
  7522. -     u_short    ler2_tlen;        /* +0x0016 */
  7523. -     /* receive message descriptors */
  7524. -     struct    lermd {            /* +0x0018 */
  7525. -         u_short    rmd0;
  7526. -         u_short    rmd1;
  7527. -         short    rmd2;
  7528. -         u_short    rmd3;
  7529. -     } ler2_rmd[LERBUF];
  7530. -     /* transmit message descriptors */
  7531. -     struct    letmd {            /* +0x0058 */
  7532. -         u_short    tmd0;
  7533. -         u_short    tmd1;
  7534. -         short    tmd2;
  7535. -         u_short    tmd3;
  7536. -     } ler2_tmd[LETBUF];
  7537. -     char    ler2_rbuf[LERBUF][LEMTU]; /* +0x0060 */
  7538. -     char    ler2_tbuf[LETBUF][LEMTU]; /* +0x2FD0 */
  7539. - };
  7540. - #if 0
  7541. - /*
  7542. -  * Control and status bits -- lereg0
  7543. -  */
  7544. - #define    LE_IE        0x80        /* interrupt enable */
  7545. - #define    LE_IR        0x40        /* interrupt requested */
  7546. - #define    LE_LOCK        0x08        /* lock status register */
  7547. - #define    LE_ACK        0x04        /* ack of lock */
  7548. - #define    LE_JAB        0x02        /* loss of tx clock (???) */
  7549. - #define LE_IPL(x)    ((((x) >> 4) & 0x3) + 3)
  7550. - #endif
  7551. - /*
  7552. -  * Control and status bits -- lereg1
  7553. -  */
  7554. - #define    LE_CSR0        0
  7555. - #define    LE_CSR1        1
  7556. - #define    LE_CSR2        2
  7557. - #define    LE_CSR3        3
  7558. - #define    LE_SERR        0x8000
  7559. - #define    LE_BABL        0x4000
  7560. - #define    LE_CERR        0x2000
  7561. - #define    LE_MISS        0x1000
  7562. - #define    LE_MERR        0x0800
  7563. - #define    LE_RINT        0x0400
  7564. - #define    LE_TINT        0x0200
  7565. - #define    LE_IDON        0x0100
  7566. - #define    LE_INTR        0x0080
  7567. - #define    LE_INEA        0x0040
  7568. - #define    LE_RXON        0x0020
  7569. - #define    LE_TXON        0x0010
  7570. - #define    LE_TDMD        0x0008
  7571. - #define    LE_STOP        0x0004
  7572. - #define    LE_STRT        0x0002
  7573. - #define    LE_INIT        0x0001
  7574. - #define    LE_BSWP        0x4
  7575. - #define    LE_MODE        0x0
  7576. - /*
  7577. -  * Control and status bits -- lereg2
  7578. -  */
  7579. - #define    LE_OWN        0x8000
  7580. - #define    LE_ERR        0x4000
  7581. - #define    LE_STP        0x0200
  7582. - #define    LE_ENP        0x0100
  7583. - #define    LE_FRAM        0x2000
  7584. - #define    LE_OFLO        0x1000
  7585. - #define    LE_CRC        0x0800
  7586. - #define    LE_RBUFF    0x0400
  7587. - #define    LE_MORE        0x1000
  7588. - #define    LE_ONE        0x0800
  7589. - #define    LE_DEF        0x0400
  7590. - #define    LE_TBUFF    0x8000
  7591. - #define    LE_UFLO        0x4000
  7592. - #define    LE_LCOL        0x1000
  7593. - #define    LE_LCAR        0x0800
  7594. - #define    LE_RTRY        0x0400
  7595. --- 0 ----
  7596. *** /dev/null
  7597. --- NetBSD/src/sys/arch/amiga/dev/if_zed.c
  7598. ***************
  7599. *** 0 ****
  7600. --- 1,1238 ----
  7601. + /*    $NetBSD: if_zed.c,v 1.15 1995/08/20 02:52:48 chopps Exp $    */
  7602. + /*
  7603. +  * Device driver for National Semiconductor DS8390/WD83C690 based ethernet
  7604. +  * adapters.
  7605. +  *
  7606. +  * Copyright (c) 1994, 1995 Charles M. Hannum.  All rights reserved.
  7607. +  *
  7608. +  * Copyright (C) 1993, David Greenman.  This software may be used, modified,
  7609. +  * copied, distributed, and sold, in both source and binary form provided that
  7610. +  * the above copyright and these terms are retained.  Under no circumstances is
  7611. +  * the author responsible for the proper functioning of this software, nor does
  7612. +  * the author assume any responsibility for damages incurred with its use.
  7613. +  *
  7614. +  * Currently supports the Hydra Systems ethernet card.
  7615. +  */
  7616. + #include "bpfilter.h"
  7617. + #include <sys/param.h>
  7618. + #include <sys/systm.h>
  7619. + #include <sys/errno.h>
  7620. + #include <sys/ioctl.h>
  7621. + #include <sys/mbuf.h>
  7622. + #include <sys/socket.h>
  7623. + #include <sys/syslog.h>
  7624. + #include <sys/device.h>
  7625. + #include <net/if.h>
  7626. + #include <net/if_dl.h>
  7627. + #include <net/if_types.h>
  7628. + #include <net/netisr.h>
  7629. + #ifdef INET
  7630. + #include <netinet/in.h>
  7631. + #include <netinet/in_systm.h>
  7632. + #include <netinet/in_var.h>
  7633. + #include <netinet/ip.h>
  7634. + #include <netinet/if_ether.h>
  7635. + #endif
  7636. + #ifdef NS
  7637. + #include <netns/ns.h>
  7638. + #include <netns/ns_if.h>
  7639. + #endif
  7640. + #if NBPFILTER > 0
  7641. + #include <net/bpf.h>
  7642. + #include <net/bpfdesc.h>
  7643. + #endif
  7644. + #include <machine/cpu.h>
  7645. + #include <machine/mtpr.h>
  7646. + #include <amiga/amiga/device.h>
  7647. + #include <amiga/amiga/isr.h>
  7648. + #include <amiga/dev/zbusvar.h>
  7649. + #include <dev/ic/dp8390reg.h>
  7650. + #include <amiga/dev/if_zedreg.h>
  7651. + #define HYDRA_MANID    2121
  7652. + #define HYDRA_PRODID    1
  7653. + #define ASDG_MANID    1023
  7654. + #define ASDG_PRODID    254
  7655. + /*
  7656. +  * zed_softc: per line info and status
  7657. +  */
  7658. + struct zed_softc {
  7659. +     struct    device sc_dev;
  7660. +     struct    isr sc_isr;
  7661. +     struct    arpcom sc_arpcom;    /* ethernet common */
  7662. +     u_char    volatile *nic_addr;    /* NIC (DS8390) I/O address */
  7663. +     u_char    cr_proto;    /* values always set in CR */
  7664. +     caddr_t    mem_start;    /* NIC memory start address */
  7665. +     caddr_t    mem_end;    /* NIC memory end address */
  7666. +     u_long    mem_size;    /* total NIC memory size */
  7667. +     caddr_t    mem_ring;    /* start of RX ring-buffer (in NIC mem) */
  7668. +     u_char    xmit_busy;    /* transmitter is busy */
  7669. +     u_char    txb_cnt;    /* number of transmit buffers */
  7670. +     u_char    txb_inuse;    /* number of TX buffers currently in-use*/
  7671. +     u_char    txb_new;    /* pointer to where new buffer will be added */
  7672. +     u_char    txb_next_tx;    /* pointer to next buffer ready to xmit */
  7673. +     u_short    txb_len[8];    /* buffered xmit buffer lengths */
  7674. +     u_char    tx_page_start;    /* first page of TX buffer area */
  7675. +     u_char    rec_page_start;    /* first page of RX ring-buffer */
  7676. +     u_char    rec_page_stop;    /* last page of RX ring-buffer */
  7677. +     u_char    next_packet;    /* pointer to next unread RX packet */
  7678. + };
  7679. + int zedmatch __P((struct device *, void *, void *));
  7680. + void zedattach __P((struct device *, struct device *, void *));
  7681. + int zedintr __P((struct zed_softc *));
  7682. + int zed_ioctl __P((struct ifnet *, u_long, caddr_t));
  7683. + void zed_start __P((struct ifnet *));
  7684. + void zed_watchdog __P((/* short */));
  7685. + void zed_reset __P((struct zed_softc *));
  7686. + void zed_init __P((struct zed_softc *));
  7687. + void zed_stop __P((struct zed_softc *));
  7688. + void zed_getmcaf __P((struct arpcom *, u_long *));
  7689. + u_short zed_put __P((struct zed_softc *, struct mbuf *, caddr_t));
  7690. + #define inline    /* XXX for debugging porpoises */
  7691. + void zed_get_packet __P((/* struct zed_softc *, caddr_t, u_short */));
  7692. + static inline void zed_rint __P((struct zed_softc *));
  7693. + static inline void zed_xmit __P((struct zed_softc *));
  7694. + static inline caddr_t zed_ring_copy __P((/* struct zed_softc *, caddr_t, caddr_t,
  7695. +                     u_short */));
  7696. + struct cfdriver zedcd = {
  7697. +     NULL, "zed", zedmatch, zedattach, DV_IFNET, sizeof(struct zed_softc)
  7698. + };
  7699. + #define    ETHER_MIN_LEN    64
  7700. + #define    ETHER_MAX_LEN    1518
  7701. + #define    ETHER_ADDR_LEN    6
  7702. + static inline void
  7703. + NIC_PUT(sc, off, val)
  7704. +     struct zed_softc *sc;
  7705. +     int off;
  7706. +     u_char val;
  7707. + {
  7708. +     sc->nic_addr[off * 2] = val;
  7709. + #ifdef not_def
  7710. +     /*
  7711. +      * This was being used to *slow* access to the bus.  I don't
  7712. +      * believe it is needed but I'll leave it around incase probelms
  7713. +      * pop-up
  7714. +      */
  7715. +     (void)ciaa.pra;
  7716. + #endif
  7717. + }
  7718. + static inline u_char
  7719. + NIC_GET(sc, off)
  7720. +     struct zed_softc *sc;
  7721. +     int off;
  7722. + {
  7723. +     register u_char val;
  7724. +     val = sc->nic_addr[off * 2];
  7725. + #ifdef not_def
  7726. +     /*
  7727. +      * This was being used to *slow* access to the bus.  I don't
  7728. +      * believe it is needed but I'll leave it around incase probelms
  7729. +      * pop-up
  7730. +      */
  7731. +     (void)ciaa.pra;
  7732. + #endif
  7733. +     return (val);
  7734. + }
  7735. + /*
  7736. +  * Memory copy, copies word at time.
  7737. +  */
  7738. + static inline void
  7739. + word_copy(a, b, len)
  7740. +     caddr_t a, b;
  7741. +     int len;
  7742. + {
  7743. +     u_short *x = (u_short *)a,
  7744. +         *y = (u_short *)b;
  7745. +     len >>= 1;
  7746. +     while (len--)
  7747. +         *y++ = *x++;
  7748. + }
  7749. + int
  7750. + zedmatch(parent, match, aux)
  7751. +     struct device *parent;
  7752. +     void *match, *aux;
  7753. + {
  7754. +     struct zbus_args *zap = aux;
  7755. +     if (zap->manid == HYDRA_MANID && zap->prodid == HYDRA_PRODID)
  7756. +         return (1);
  7757. +     else if (zap->manid == ASDG_MANID && zap->prodid == ASDG_PRODID)
  7758. +         return (1);
  7759. +     return (0);
  7760. + }
  7761. + void
  7762. + zedattach(parent, self, aux)
  7763. +     struct device *parent, *self;
  7764. +     void *aux;
  7765. + {
  7766. +     struct zed_softc *sc = (void *)self;
  7767. +     struct zbus_args *zap = aux;
  7768. +     struct cfdata *cf = sc->sc_dev.dv_cfdata;
  7769. +     struct ifnet *ifp = &sc->sc_arpcom.ac_if;
  7770. +     u_char *prom;
  7771. +     int i;
  7772. +     if (zap->manid == HYDRA_MANID) {
  7773. +         sc->mem_start = zap->va;
  7774. +         sc->nic_addr = sc->mem_start + HYDRA_NIC_BASE;
  7775. +         prom = (u_char *)sc->mem_start + HYDRA_ADDRPROM;
  7776. +     } else {
  7777. +         sc->mem_start = zap->va + 0x8000;
  7778. +         sc->nic_addr = zap->va + ASDG_NIC_BASE;
  7779. +         prom = (u_char *)sc->nic_addr + ASDG_ADDRPROM;
  7780. +     }
  7781. +     sc->cr_proto = ED_CR_RD2;
  7782. +     sc->tx_page_start = 0;
  7783. + #define    memsize    16384
  7784. +     sc->mem_size = memsize;
  7785. +     sc->mem_end = sc->mem_start + memsize;
  7786. +     /*
  7787. +      * Use one xmit buffer if < 16k, two buffers otherwise (if not told
  7788. +      * otherwise).
  7789. +      */
  7790. +     if ((memsize < 16384) || (cf->cf_flags & ED_FLAGS_NO_MULTI_BUFFERING))
  7791. +         sc->txb_cnt = 1;
  7792. +     else
  7793. +         sc->txb_cnt = 2;
  7794. +     sc->rec_page_start = sc->tx_page_start + sc->txb_cnt * ED_TXBUF_SIZE;
  7795. +     sc->rec_page_stop = sc->tx_page_start + (memsize >> ED_PAGE_SHIFT);
  7796. +     sc->mem_ring =
  7797. +         sc->mem_start + ((sc->txb_cnt * ED_TXBUF_SIZE) << ZED_PAGE_SHIFT);
  7798. + #undef    memsize
  7799. +     /*
  7800. +      * read the ethernet address from the board
  7801. +      */
  7802. +     for (i = 0; i < ETHER_ADDR_LEN; i++)
  7803. +         sc->sc_arpcom.ac_enaddr[i] = *(prom + 2 * i);
  7804. +     /* Set interface to stopped condition (reset). */
  7805. +     zed_stop(sc);
  7806. +     /* Initialize ifnet structure. */
  7807. +     ifp->if_unit = sc->sc_dev.dv_unit;
  7808. +     ifp->if_name = zedcd.cd_name;
  7809. +     ifp->if_start = zed_start;
  7810. +     ifp->if_ioctl = zed_ioctl;
  7811. +     ifp->if_watchdog = zed_watchdog;
  7812. +     ifp->if_flags =
  7813. +         IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST;
  7814. +     /* Attach the interface. */
  7815. +     if_attach(ifp);
  7816. +     ether_ifattach(ifp);
  7817. +     /* Print additional info when attached. */
  7818. +     printf(": address %s\n", ether_sprintf(sc->sc_arpcom.ac_enaddr));
  7819. + #if NBPFILTER > 0
  7820. +     bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header));
  7821. + #endif
  7822. +     sc->sc_isr.isr_intr = zedintr;
  7823. +     sc->sc_isr.isr_arg = sc;
  7824. +     sc->sc_isr.isr_ipl = 2;
  7825. +     add_isr(&sc->sc_isr);
  7826. + }
  7827. + /*
  7828. +  * Reset interface.
  7829. +  */
  7830. + void
  7831. + zed_reset(sc)
  7832. +     struct zed_softc *sc;
  7833. + {
  7834. +     int s;
  7835. +     s = splimp();
  7836. +     zed_stop(sc);
  7837. +     zed_init(sc);
  7838. +     splx(s);
  7839. +     log(LOG_ERR, "%s: reset\n", sc->sc_dev.dv_xname);
  7840. + }
  7841. + /*
  7842. +  * Take interface offline.
  7843. +  */
  7844. + void
  7845. + zed_stop(sc)
  7846. +     struct zed_softc *sc;
  7847. + {
  7848. +     int n = 5000;
  7849. +     /* Stop everything on the interface, and select page 0 registers. */
  7850. +     NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ZED_CR_PAGE_0 | ZED_CR_STP);
  7851. +     /*
  7852. +      * Wait for interface to enter stopped state, but limit # of checks to
  7853. +      * 'n' (about 5ms).  It shouldn't even take 5us on modern DS8390's, but
  7854. +      * just in case it's an old one.
  7855. +      */
  7856. +     while (((NIC_GET(sc, ED_P0_ISR) & ZED_ISR_RST) == 0) && --n);
  7857. + }
  7858. + /*
  7859. +  * Device timeout/watchdog routine.  Entered if the device neglects to generate
  7860. +  * an interrupt after a transmit has been started on it.
  7861. +  */
  7862. + void
  7863. + zed_watchdog(unit)
  7864. +     short unit;
  7865. + {
  7866. +     struct zed_softc *sc = zedcd.cd_devs[unit];
  7867. +     log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname);
  7868. +     ++sc->sc_arpcom.ac_if.if_oerrors;
  7869. +     zed_reset(sc);
  7870. + }
  7871. + /*
  7872. +  * Initialize device.
  7873. +  */
  7874. + void
  7875. + zed_init(sc)
  7876. +     struct zed_softc *sc;
  7877. + {
  7878. +     struct ifnet *ifp = &sc->sc_arpcom.ac_if;
  7879. +     int i, s;
  7880. +     u_char command;
  7881. +     u_long mcaf[2];
  7882. +     /*
  7883. +      * Initialize the NIC in the exact order outlined in the NS manual.
  7884. +      * This init procedure is "mandatory"...don't change what or when
  7885. +      * things happen.
  7886. +      */
  7887. +     s = splimp();
  7888. +     /* Reset transmitter flags. */
  7889. +     sc->xmit_busy = 0;
  7890. +     sc->sc_arpcom.ac_if.if_timer = 0;
  7891. +     sc->txb_inuse = 0;
  7892. +     sc->txb_new = 0;
  7893. +     sc->txb_next_tx = 0;
  7894. +     /* Set interface for page 0, remote DMA complete, stopped. */
  7895. +     NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ZED_CR_PAGE_0 | ZED_CR_STP);
  7896. +     /*
  7897. +      * Set FIFO threshold to 8, No auto-init Remote DMA, byte
  7898. +      * order=68k, word-wide DMA xfers,
  7899. +      * XXX changed to use 2 word threshhold
  7900. +      */
  7901. +     NIC_PUT(sc, ED_P0_DCR,
  7902. +         ED_DCR_FT0 | ZED_DCR_WTS | ZED_DCR_LS | ZED_DCR_BOS);
  7903. +     /* Clear remote byte count registers. */
  7904. +     NIC_PUT(sc, ED_P0_RBCR0, 0);
  7905. +     NIC_PUT(sc, ED_P0_RBCR1, 0);
  7906. +     /* Tell RCR to do nothing for now. */
  7907. +     NIC_PUT(sc, ED_P0_RCR, ZED_RCR_MON);
  7908. +     /* Place NIC in internal loopback mode. */
  7909. +     NIC_PUT(sc, ED_P0_TCR, ZED_TCR_LB0);
  7910. +     /* Initialize receive buffer ring. */
  7911. +     NIC_PUT(sc, ED_P0_BNRY, sc->rec_page_start);
  7912. +     NIC_PUT(sc, ED_P0_PSTART, sc->rec_page_start);
  7913. +     NIC_PUT(sc, ED_P0_PSTOP, sc->rec_page_stop);
  7914. +     /*
  7915. +      * Clear all interrupts.  A '1' in each bit position clears the
  7916. +      * corresponding flag.
  7917. +      */
  7918. +     NIC_PUT(sc, ED_P0_ISR, 0xff);
  7919. +     /*
  7920. +      * Enable the following interrupts: receive/transmit complete,
  7921. +      * receive/transmit error, and Receiver OverWrite.
  7922. +      *
  7923. +      * Counter overflow and Remote DMA complete are *not* enabled.
  7924. +      */
  7925. +     NIC_PUT(sc, ED_P0_IMR,
  7926. +         ED_IMR_PRXE | ZED_IMR_PTXE | ZED_IMR_RXEE | ZED_IMR_TXEE |
  7927. +         ED_IMR_OVWE);
  7928. +     /* Program command register for page 1. */
  7929. +     NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ZED_CR_PAGE_1 | ZED_CR_STP);
  7930. +     /* Copy out our station address. */
  7931. +     for (i = 0; i < ETHER_ADDR_LEN; ++i)
  7932. +         NIC_PUT(sc, ED_P1_PAR0 + i, sc->sc_arpcom.ac_enaddr[i]);
  7933. +     /* Set multicast filter on chip. */
  7934. +     zed_getmcaf(&sc->sc_arpcom, mcaf);
  7935. +     for (i = 0; i < 8; i++)
  7936. +         NIC_PUT(sc, ED_P1_MAR0 + i, ((u_char *)mcaf)[i]);
  7937. +     /*
  7938. +      * Set current page pointer to one page after the boundary pointer, as
  7939. +      * recommended in the National manual.
  7940. +      */
  7941. +     sc->next_packet = sc->rec_page_start + 1;
  7942. +     NIC_PUT(sc, ED_P1_CURR, sc->next_packet);
  7943. +     /* Program command register for page 0. */
  7944. +     NIC_PUT(sc, ED_P1_CR, sc->cr_proto | ZED_CR_PAGE_0 | ZED_CR_STP);
  7945. +     i = ED_RCR_AB | ZED_RCR_AM;
  7946. +     if (ifp->if_flags & IFF_PROMISC) {
  7947. +         /*
  7948. +          * Set promiscuous mode.  Multicast filter was set earlier so
  7949. +          * that we should receive all multicast packets.
  7950. +          */
  7951. +         i |= ED_RCR_PRO | ZED_RCR_AR | ZED_RCR_SEP;
  7952. +     }
  7953. +     NIC_PUT(sc, ED_P0_RCR, i);
  7954. +     /* Take interface out of loopback. */
  7955. +     NIC_PUT(sc, ED_P0_TCR, 0);
  7956. +     /* Fire up the interface. */
  7957. +     NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ZED_CR_PAGE_0 | ZED_CR_STA);
  7958. +     /* Set 'running' flag, and clear output active flag. */
  7959. +     ifp->if_flags |= IFF_RUNNING;
  7960. +     ifp->if_flags &= ~IFF_OACTIVE;
  7961. +     /* ...and attempt to start output. */
  7962. +     zed_start(ifp);
  7963. +     splx(s);
  7964. + }
  7965. + /*
  7966. +  * This routine actually starts the transmission on the interface.
  7967. +  */
  7968. + static inline void
  7969. + zed_xmit(sc)
  7970. +     struct zed_softc *sc;
  7971. + {
  7972. +     struct ifnet *ifp = &sc->sc_arpcom.ac_if;
  7973. +     u_short len;
  7974. +     len = sc->txb_len[sc->txb_next_tx];
  7975. +     /* Set NIC for page 0 register access. */
  7976. +     NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ZED_CR_PAGE_0 | ZED_CR_STA);
  7977. +     /* Set TX buffer start page. */
  7978. +     NIC_PUT(sc, ED_P0_TPSR, sc->tx_page_start +
  7979. +         sc->txb_next_tx * ED_TXBUF_SIZE);
  7980. +     /* Set TX length. */
  7981. +     NIC_PUT(sc, ED_P0_TBCR0, len);
  7982. +     NIC_PUT(sc, ED_P0_TBCR1, len >> 8);
  7983. +     /* Set page 0, remote DMA complete, transmit packet, and *start*. */
  7984. +     NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ZED_CR_PAGE_0 | ZED_CR_TXP | ZED_CR_STA);
  7985. +     sc->xmit_busy = 1;
  7986. +     /* Point to next transmit buffer slot and wrap if necessary. */
  7987. +     sc->txb_next_tx++;
  7988. +     if (sc->txb_next_tx == sc->txb_cnt)
  7989. +         sc->txb_next_tx = 0;
  7990. +     /* Set a timer just in case we never hear from the board again. */
  7991. +     ifp->if_timer = 2;
  7992. + }
  7993. + /*
  7994. +  * Start output on interface.
  7995. +  * We make two assumptions here:
  7996. +  *  1) that the current priority is set to splimp _before_ this code
  7997. +  *     is called *and* is returned to the appropriate priority after
  7998. +  *     return
  7999. +  *  2) that the IFF_OACTIVE flag is checked before this code is called
  8000. +  *     (i.e. that the output part of the interface is idle)
  8001. +  */
  8002. + void
  8003. + zed_start(ifp)
  8004. +     struct ifnet *ifp;
  8005. + {
  8006. +     struct zed_softc *sc = zedcd.cd_devs[ifp->if_unit];
  8007. +     struct mbuf *m0, *m;
  8008. +     caddr_t buffer;
  8009. +     int len;
  8010. + outloop:
  8011. +     /*
  8012. +      * First, see if there are buffered packets and an idle transmitter -
  8013. +      * should never happen at this point.
  8014. +      */
  8015. +     if (sc->txb_inuse && (sc->xmit_busy == 0)) {
  8016. +         printf("%s: packets buffered, but transmitter idle\n",
  8017. +             sc->sc_dev.dv_xname);
  8018. +         zed_xmit(sc);
  8019. +     }
  8020. +     /* See if there is room to put another packet in the buffer. */
  8021. +     if (sc->txb_inuse == sc->txb_cnt) {
  8022. +         /* No room.  Indicate this to the outside world and exit. */
  8023. +         ifp->if_flags |= IFF_OACTIVE;
  8024. +         return;
  8025. +     }
  8026. +     IF_DEQUEUE(&sc->sc_arpcom.ac_if.if_snd, m);
  8027. +     if (m == 0) {
  8028. +         /*
  8029. +          * We are using the !OACTIVE flag to indicate to the outside
  8030. +          * world that we can accept an additional packet rather than
  8031. +          * that the transmitter is _actually_ active.  Indeed, the
  8032. +          * transmitter may be active, but if we haven't filled all the
  8033. +          * buffers with data then we still want to accept more.
  8034. +          */
  8035. +         ifp->if_flags &= ~IFF_OACTIVE;
  8036. +         return;
  8037. +     }
  8038. +     /* Copy the mbuf chain into the transmit buffer. */
  8039. +     m0 = m;
  8040. +     /* txb_new points to next open buffer slot. */
  8041. +     buffer = sc->mem_start + ((sc->txb_new * ED_TXBUF_SIZE) << ZED_PAGE_SHIFT);
  8042. +     len = zed_put(sc, m, buffer);
  8043. +     sc->txb_len[sc->txb_new] = max(len, ETHER_MIN_LEN);
  8044. +     sc->txb_inuse++;
  8045. +     /* Point to next buffer slot and wrap if necessary. */
  8046. +     if (++sc->txb_new == sc->txb_cnt)
  8047. +         sc->txb_new = 0;
  8048. +     if (sc->xmit_busy == 0)
  8049. +         zed_xmit(sc);
  8050. + #if NBPFILTER > 0
  8051. +     /* Tap off here if there is a BPF listener. */
  8052. +     if (sc->sc_arpcom.ac_if.if_bpf)
  8053. +         bpf_mtap(sc->sc_arpcom.ac_if.if_bpf, m0);
  8054. + #endif
  8055. +     m_freem(m0);
  8056. +     /* Loop back to the top to possibly buffer more packets. */
  8057. +     goto outloop;
  8058. + }
  8059. + /*
  8060. +  * Ethernet interface receiver interrupt.
  8061. +  */
  8062. + static inline void
  8063. + zed_rint(sc)
  8064. +     struct zed_softc *sc;
  8065. + {
  8066. +     u_char boundary, current;
  8067. +     u_short len;
  8068. +     u_char nlen;
  8069. +     struct zed_ring packet_hdr;
  8070. +     caddr_t packet_ptr;
  8071. + loop:
  8072. +     /* Set NIC to page 1 registers to get 'current' pointer. */
  8073. +     NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ZED_CR_PAGE_1 | ZED_CR_STA);
  8074. +     /*
  8075. +      * 'sc->next_packet' is the logical beginning of the ring-buffer - i.e.
  8076. +      * it points to where new data has been buffered.  The 'CURR' (current)
  8077. +      * register points to the logical end of the ring-buffer - i.e. it
  8078. +      * points to where additional new data will be added.  We loop here
  8079. +      * until the logical beginning equals the logical end (or in other
  8080. +      * words, until the ring-buffer is empty).
  8081. +      */
  8082. +     current = NIC_GET(sc, ED_P1_CURR);
  8083. +     if (sc->next_packet == current)
  8084. +         return;
  8085. +     /* Set NIC to page 0 registers to update boundary register. */
  8086. +     NIC_PUT(sc, ED_P1_CR, sc->cr_proto | ZED_CR_PAGE_0 | ZED_CR_STA);
  8087. +     do {
  8088. +         /* Get pointer to this buffer's header structure. */
  8089. +         packet_ptr = sc->mem_ring +
  8090. +             ((sc->next_packet - sc->rec_page_start) << ED_PAGE_SHIFT);
  8091. +         /*
  8092. +          * The byte count includes a 4 byte header that was added by
  8093. +          * the NIC.
  8094. +          */
  8095. +         packet_hdr = *(struct zed_ring *)packet_ptr;
  8096. +         packet_hdr.count = ((packet_hdr.count >> 8) & 0xff)
  8097. +              | ((packet_hdr.count & 0xff) << 8);
  8098. +         len = packet_hdr.count;
  8099. +         /*
  8100. +          * Try do deal with old, buggy chips that sometimes duplicate
  8101. +          * the low byte of the length into the high byte.  We do this
  8102. +          * by simply ignoring the high byte of the length and always
  8103. +          * recalculating it.
  8104. +          *
  8105. +          * NOTE: sc->next_packet is pointing at the current packet.
  8106. +          */
  8107. +         if (packet_hdr.next_packet >= sc->next_packet)
  8108. +             nlen = (packet_hdr.next_packet - sc->next_packet);
  8109. +         else
  8110. +             nlen = ((packet_hdr.next_packet - sc->rec_page_start) +
  8111. +                 (sc->rec_page_stop - sc->next_packet));
  8112. +         --nlen;
  8113. +         if ((len & ED_PAGE_MASK) + sizeof(packet_hdr) > ZED_PAGE_SIZE)
  8114. +             --nlen;
  8115. +         len = (len & ED_PAGE_MASK) | (nlen << ZED_PAGE_SHIFT);
  8116. + #ifdef DIAGNOSTIC
  8117. +         if (len != packet_hdr.count) {
  8118. +             printf("%s: length does not match next packet pointer\n",
  8119. +                 sc->sc_dev.dv_xname);
  8120. +             printf("%s: len %04x nlen %04x start %02x first %02x curr %02x next %02x stop %02x\n",
  8121. +                 sc->sc_dev.dv_xname, packet_hdr.count, len,
  8122. +                 sc->rec_page_start, sc->next_packet, current,
  8123. +                 packet_hdr.next_packet, sc->rec_page_stop);
  8124. +         }
  8125. + #endif
  8126. +         /*
  8127. +          * Be fairly liberal about what we allow as a "reasonable"
  8128. +          * length so that a [crufty] packet will make it to BPF (and
  8129. +          * can thus be analyzed).  Note that all that is really
  8130. +          * important is that we have a length that will fit into one
  8131. +          * mbuf cluster or less; the upper layer protocols can then
  8132. +          * figure out the length from their own length field(s).
  8133. +          *
  8134. +          * MCLBYTES may be less than a valid packet len.  Thus
  8135. +          * we use a constant that is large enough.
  8136. +          */
  8137. +         if (len <= 2048 &&
  8138. +             packet_hdr.next_packet >= sc->rec_page_start &&
  8139. +             packet_hdr.next_packet < sc->rec_page_stop) {
  8140. +             /* Go get packet. */
  8141. +             zed_get_packet(sc, packet_ptr + sizeof(struct zed_ring),
  8142. +                 len - sizeof(struct zed_ring));
  8143. +             ++sc->sc_arpcom.ac_if.if_ipackets;
  8144. +         } else {
  8145. +             /* Really BAD.  The ring pointers are corrupted. */
  8146. +             log(LOG_ERR,
  8147. +                 "%s: NIC memory corrupt - invalid packet length %d\n",
  8148. +                 sc->sc_dev.dv_xname, len);
  8149. +             ++sc->sc_arpcom.ac_if.if_ierrors;
  8150. +             zed_reset(sc);
  8151. +             return;
  8152. +         }
  8153. +         /* Update next packet pointer. */
  8154. +         sc->next_packet = packet_hdr.next_packet;
  8155. +         /*
  8156. +          * Update NIC boundary pointer - being careful to keep it one
  8157. +          * buffer behind (as recommended by NS databook).
  8158. +          */
  8159. +         boundary = sc->next_packet - 1;
  8160. +         if (boundary < sc->rec_page_start)
  8161. +             boundary = sc->rec_page_stop - 1;
  8162. +         NIC_PUT(sc, ED_P0_BNRY, boundary);
  8163. +     } while (sc->next_packet != current);
  8164. +     goto loop;
  8165. + }
  8166. + /* Ethernet interface interrupt processor. */
  8167. + int
  8168. + zedintr(sc)
  8169. +     struct zed_softc *sc;
  8170. + {
  8171. +     u_char isr;
  8172. +     /* Set NIC to page 0 registers. */
  8173. +     NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ZED_CR_PAGE_0 | ZED_CR_STA);
  8174. +     isr = NIC_GET(sc, ED_P0_ISR);
  8175. +     if (!isr)
  8176. +         return (0);
  8177. +     /* Loop until there are no more new interrupts. */
  8178. +     for (;;) {
  8179. +         /*
  8180. +          * Reset all the bits that we are 'acknowledging' by writing a
  8181. +          * '1' to each bit position that was set.
  8182. +          * (Writing a '1' *clears* the bit.)
  8183. +          */
  8184. +         NIC_PUT(sc, ED_P0_ISR, isr);
  8185. +         /*
  8186. +          * Handle transmitter interrupts.  Handle these first because
  8187. +          * the receiver will reset the board under some conditions.
  8188. +          */
  8189. +         if (isr & (ED_ISR_PTX | ZED_ISR_TXE)) {
  8190. +             u_char collisions = NIC_GET(sc, ED_P0_NCR) & 0x0f;
  8191. +             /*
  8192. +              * Check for transmit error.  If a TX completed with an
  8193. +              * error, we end up throwing the packet away.  Really
  8194. +              * the only error that is possible is excessive
  8195. +              * collisions, and in this case it is best to allow the
  8196. +              * automatic mechanisms of TCP to backoff the flow.  Of
  8197. +              * course, with UDP we're screwed, but this is expected
  8198. +              * when a network is heavily loaded.
  8199. +              */
  8200. +             (void) NIC_GET(sc, ED_P0_TSR);
  8201. +             if (isr & ED_ISR_TXE) {
  8202. +                 /*
  8203. +                  * Excessive collisions (16).
  8204. +                  */
  8205. +                 if ((NIC_GET(sc, ED_P0_TSR) & ZED_TSR_ABT)
  8206. +                     && (collisions == 0)) {
  8207. +                     /*
  8208. +                      * When collisions total 16, the P0_NCR
  8209. +                      * will indicate 0, and the TSR_ABT is
  8210. +                      * set.
  8211. +                      */
  8212. +                     collisions = 16;
  8213. +                 }
  8214. +                 /* Update output errors counter. */
  8215. +                 ++sc->sc_arpcom.ac_if.if_oerrors;
  8216. +             } else {
  8217. +                 /*
  8218. +                  * Update total number of successfully
  8219. +                  * transmitted packets.
  8220. +                  */
  8221. +                 ++sc->sc_arpcom.ac_if.if_opackets;
  8222. +             }
  8223. +             /* Reset TX busy and output active flags. */
  8224. +             sc->xmit_busy = 0;
  8225. +             sc->sc_arpcom.ac_if.if_flags &= ~IFF_OACTIVE;
  8226. +             /* Clear watchdog timer. */
  8227. +             sc->sc_arpcom.ac_if.if_timer = 0;
  8228. +             /*
  8229. +              * Add in total number of collisions on last
  8230. +              * transmission.
  8231. +              */
  8232. +             sc->sc_arpcom.ac_if.if_collisions += collisions;
  8233. +             /*
  8234. +              * Decrement buffer in-use count if not zero (can only
  8235. +              * be zero if a transmitter interrupt occured while not
  8236. +              * actually transmitting).
  8237. +              * If data is ready to transmit, start it transmitting,
  8238. +              * otherwise defer until after handling receiver.
  8239. +              */
  8240. +             if (sc->txb_inuse && --sc->txb_inuse)
  8241. +                 zed_xmit(sc);
  8242. +         }
  8243. +         /* Handle receiver interrupts. */
  8244. +         if (isr & (ED_ISR_PRX | ZED_ISR_RXE | ZED_ISR_OVW)) {
  8245. +             /*
  8246. +              * Overwrite warning.  In order to make sure that a
  8247. +              * lockup of the local DMA hasn't occurred, we reset
  8248. +              * and re-init the NIC.  The NSC manual suggests only a
  8249. +              * partial reset/re-init is necessary - but some chips
  8250. +              * seem to want more.  The DMA lockup has been seen
  8251. +              * only with early rev chips - Methinks this bug was
  8252. +              * fixed in later revs.  -DG
  8253. +              */
  8254. +             if (isr & ED_ISR_OVW) {
  8255. +                 ++sc->sc_arpcom.ac_if.if_ierrors;
  8256. + #ifdef DIAGNOSTIC
  8257. +                 log(LOG_WARNING,
  8258. +                     "%s: warning - receiver ring buffer overrun\n",
  8259. +                     sc->sc_dev.dv_xname);
  8260. + #endif
  8261. +                 /* Stop/reset/re-init NIC. */
  8262. +                 zed_reset(sc);
  8263. +             } else {
  8264. +                 /*
  8265. +                  * Receiver Error.  One or more of: CRC error,
  8266. +                  * frame alignment error FIFO overrun, or
  8267. +                  * missed packet.
  8268. +                  */
  8269. +                 if (isr & ED_ISR_RXE) {
  8270. +                     ++sc->sc_arpcom.ac_if.if_ierrors;
  8271. + #ifdef ZED_DEBUG
  8272. +                     printf("%s: receive error %x\n",
  8273. +                         sc->sc_dev.dv_xname,
  8274. +                         NIC_GET(sc, ED_P0_RSR));
  8275. + #endif
  8276. +                 }
  8277. +                 /*
  8278. +                  * Go get the packet(s).
  8279. +                  * XXX - Doing this on an error is dubious
  8280. +                  * because there shouldn't be any data to get
  8281. +                  * (we've configured the interface to not
  8282. +                  * accept packets with errors).
  8283. +                  */
  8284. +                 zed_rint(sc);
  8285. +             }
  8286. +         }
  8287. +         /*
  8288. +          * If it looks like the transmitter can take more data, attempt
  8289. +          * to start output on the interface.  This is done after
  8290. +          * handling the receiver to give the receiver priority.
  8291. +          */
  8292. +         if ((sc->sc_arpcom.ac_if.if_flags & IFF_OACTIVE) == 0)
  8293. +             zed_start(&sc->sc_arpcom.ac_if);
  8294. +         /*
  8295. +          * Return NIC CR to standard state: page 0, remote DMA
  8296. +          * complete, start (toggling the TXP bit off, even if was just
  8297. +          * set in the transmit routine, is *okay* - it is 'zedge'
  8298. +          * triggered from low to high).
  8299. +          */
  8300. +         NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ZED_CR_PAGE_0 | ZED_CR_STA);
  8301. +         /*
  8302. +          * If the Network Talley Counters overflow, read them to reset
  8303. +          * them.  It appears that old 8390's won't clear the ISR flag
  8304. +          * otherwise - resulting in an infinite loop.
  8305. +          */
  8306. +         if (isr & ED_ISR_CNT) {
  8307. +             (void) NIC_GET(sc, ED_P0_CNTR0);
  8308. +             (void) NIC_GET(sc, ED_P0_CNTR1);
  8309. +             (void) NIC_GET(sc, ED_P0_CNTR2);
  8310. +         }
  8311. +         isr = NIC_GET(sc, ED_P0_ISR);
  8312. +         if (!isr)
  8313. +             return (1);
  8314. +     }
  8315. + }
  8316. + /*
  8317. +  * Process an ioctl request.  This code needs some work - it looks pretty ugly.
  8318. +  */
  8319. + int
  8320. + zed_ioctl(ifp, command, data)
  8321. +     register struct ifnet *ifp;
  8322. +     u_long command;
  8323. +     caddr_t data;
  8324. + {
  8325. +     struct zed_softc *sc = zedcd.cd_devs[ifp->if_unit];
  8326. +     register struct ifaddr *ifa = (struct ifaddr *)data;
  8327. +     struct ifreq *ifr = (struct ifreq *)data;
  8328. +     int s, error = 0;
  8329. +     s = splimp();
  8330. +     switch (command) {
  8331. +     case SIOCSIFADDR:
  8332. +         ifp->if_flags |= IFF_UP;
  8333. +         switch (ifa->ifa_addr->sa_family) {
  8334. + #ifdef INET
  8335. +         case AF_INET:
  8336. +             zed_init(sc);
  8337. +             arp_ifinit(&sc->sc_arpcom, ifa);
  8338. +             break;
  8339. + #endif
  8340. + #ifdef NS
  8341. +         /* XXX - This code is probably wrong. */
  8342. +         case AF_NS:
  8343. +             {
  8344. +             register struct ns_addr *ina = &IA_SNS(ifa)->sns_addr;
  8345. +             if (ns_nullhost(*ina))
  8346. +                 ina->x_host =
  8347. +                     *(union ns_host *)(sc->sc_arpcom.sc_enaddr);
  8348. +             else
  8349. +                 bcopy(ina->x_host.c_host,
  8350. +                     sc->sc_arpcom.ac_enaddr,
  8351. +                     sizeof(sc->sc_arpcom.ac_enaddr));
  8352. +             /* Set new address. */
  8353. +             zed_init(sc);
  8354. +             break;
  8355. +             }
  8356. + #endif
  8357. +         default:
  8358. +             zed_init(sc);
  8359. +             break;
  8360. +         }
  8361. +         break;
  8362. +     case SIOCSIFFLAGS:
  8363. +         if ((ifp->if_flags & IFF_UP) == 0 &&
  8364. +             (ifp->if_flags & IFF_RUNNING) != 0) {
  8365. +             /*
  8366. +              * If interface is marked down and it is running, then
  8367. +              * stop it.
  8368. +              */
  8369. +             zed_stop(sc);
  8370. +             ifp->if_flags &= ~IFF_RUNNING;
  8371. +         } else if ((ifp->if_flags & IFF_UP) != 0 &&
  8372. +                (ifp->if_flags & IFF_RUNNING) == 0) {
  8373. +             /*
  8374. +              * If interface is marked up and it is stopped, then
  8375. +              * start it.
  8376. +              */
  8377. +             zed_init(sc);
  8378. +         } else {
  8379. +             /*
  8380. +              * Reset the interface to pick up changes in any other
  8381. +              * flags that affect hardware registers.
  8382. +              */
  8383. +             zed_stop(sc);
  8384. +             zed_init(sc);
  8385. +         }
  8386. +         break;
  8387. +     case SIOCADDMULTI:
  8388. +     case SIOCDELMULTI:
  8389. +         /* Update our multicast list. */
  8390. +         error = (command == SIOCADDMULTI) ?
  8391. +             ether_addmulti(ifr, &sc->sc_arpcom) :
  8392. +             ether_delmulti(ifr, &sc->sc_arpcom);
  8393. +         if (error == ENETRESET) {
  8394. +             /*
  8395. +              * Multicast list has changed; set the hardware filter
  8396. +              * accordingly.
  8397. +              */
  8398. +             zed_stop(sc); /* XXX for ds_setmcaf? */
  8399. +             zed_init(sc);
  8400. +             error = 0;
  8401. +         }
  8402. +         break;
  8403. +     default:
  8404. +         error = EINVAL;
  8405. +     }
  8406. +     splx(s);
  8407. +     return (error);
  8408. + }
  8409. + /*
  8410. +  * Retreive packet from shared memory and send to the next level up via
  8411. +  * ether_input().  If there is a BPF listener, give a copy to BPF, too.
  8412. +  */
  8413. + void
  8414. + zed_get_packet(sc, buf, len)
  8415. +     struct zed_softc *sc;
  8416. +     caddr_t buf;
  8417. +     u_short len;
  8418. + {
  8419. +     struct ether_header *eh;
  8420. +     struct mbuf *m, *zed_ring_to_mbuf();
  8421. +     /* round length to word boundry */
  8422. +     len = (len + 1) & ~1;
  8423. +     /* Allocate a header mbuf. */
  8424. +     MGETHDR(m, M_DONTWAIT, MT_DATA);
  8425. +     if (m == 0)
  8426. +         return;
  8427. +     m->m_pkthdr.rcvif = &sc->sc_arpcom.ac_if;
  8428. +     m->m_pkthdr.len = len;
  8429. +     m->m_len = 0;
  8430. +     /* The following silliness is to make NFS happy. */
  8431. + #define EROUND    ((sizeof(struct ether_header) + 3) & ~3)
  8432. + #define EOFF    (EROUND - sizeof(struct ether_header))
  8433. +     /*
  8434. +      * The following assumes there is room for the ether header in the
  8435. +      * header mbuf.
  8436. +      */
  8437. +     m->m_data += EOFF;
  8438. +     eh = mtod(m, struct ether_header *);
  8439. +     word_copy(buf, mtod(m, caddr_t), sizeof(struct ether_header));
  8440. +     buf += sizeof(struct ether_header);
  8441. +     m->m_len += sizeof(struct ether_header);
  8442. +     len -= sizeof(struct ether_header);
  8443. +     /* Pull packet off interface. */
  8444. +     if (zed_ring_to_mbuf(sc, buf, m, len) == 0) {
  8445. +         m_freem(m);
  8446. +         return;
  8447. +     }
  8448. + #if NBPFILTER > 0
  8449. +     /*
  8450. +      * Check if there's a BPF listener on this interface.  If so, hand off
  8451. +      * the raw packet to bpf.
  8452. +      */
  8453. +     if (sc->sc_arpcom.ac_if.if_bpf) {
  8454. +         bpf_mtap(sc->sc_arpcom.ac_if.if_bpf, m);
  8455. +         /*
  8456. +          * Note that the interface cannot be in promiscuous mode if
  8457. +          * there are no BPF listeners.  And if we are in promiscuous
  8458. +          * mode, we have to check if this packet is really ours.
  8459. +          */
  8460. +         if ((sc->sc_arpcom.ac_if.if_flags & IFF_PROMISC) &&
  8461. +             (eh->ether_dhost[0] & 1) == 0 && /* !mcast and !bcast */
  8462. +             bcmp(eh->ether_dhost, sc->sc_arpcom.ac_enaddr,
  8463. +                 sizeof(eh->ether_dhost)) != 0) {
  8464. +             m_freem(m);
  8465. +             return;
  8466. +         }
  8467. +     }
  8468. + #endif
  8469. +     /* Fix up data start offset in mbuf to point past ether header. */
  8470. +     m_adj(m, sizeof(struct ether_header));
  8471. +     ether_input(&sc->sc_arpcom.ac_if, eh, m);
  8472. + }
  8473. + /*
  8474. +  * Supporting routines.
  8475. +  */
  8476. + /*
  8477. +  * Given a source and destination address, copy 'amount' of a packet from the
  8478. +  * ring buffer into a linear destination buffer.  Takes into account ring-wrap.
  8479. +  */
  8480. + static inline caddr_t
  8481. + zed_ring_copy(sc, src, dst, amount)
  8482. +     struct zed_softc *sc;
  8483. +     caddr_t src, dst;
  8484. +     u_short amount;
  8485. + {
  8486. +     u_short tmp_amount;
  8487. +     /* Does copy wrap to lower addr in ring buffer? */
  8488. +     if (src + amount > sc->mem_end) {
  8489. +         tmp_amount = sc->mem_end - src;
  8490. +         /* Copy amount up to end of NIC memory. */
  8491. +         word_copy(src, dst, tmp_amount);
  8492. +         amount -= tmp_amount;
  8493. +         src = sc->mem_ring;
  8494. +         dst += tmp_amount;
  8495. +     }
  8496. +     word_copy(src, dst, amount);
  8497. +     return (src + amount);
  8498. + }
  8499. + /*
  8500. +  * Copy data from receive buffer to end of mbuf chain allocate additional mbufs
  8501. +  * as needed.  Return pointer to last mbuf in chain.
  8502. +  * sc = zed info (softc)
  8503. +  * src = pointer in zed ring buffer
  8504. +  * dst = pointer to last mbuf in mbuf chain to copy to
  8505. +  * amount = amount of data to copy
  8506. +  */
  8507. + struct mbuf *
  8508. + zed_ring_to_mbuf(sc, src, dst, total_len)
  8509. +     struct zed_softc *sc;
  8510. +     caddr_t src;
  8511. +     struct mbuf *dst;
  8512. +     u_short total_len;
  8513. + {
  8514. +     register struct mbuf *m = dst;
  8515. +     /* Round the length to a word boundary. */
  8516. +     /* total_len = (total_len + 1) & ~1; */
  8517. +     while (total_len) {
  8518. +         register u_short amount = min(total_len, M_TRAILINGSPACE(m));
  8519. +         if (amount == 0) {
  8520. +             /*
  8521. +              * No more data in this mbuf; alloc another.
  8522. +              *
  8523. +              * If there is enough data for an mbuf cluster, attempt
  8524. +              * to allocate one of those, otherwise, a regular mbuf
  8525. +              * will do.
  8526. +              * Note that a regular mbuf is always required, even if
  8527. +              * we get a cluster - getting a cluster does not
  8528. +              * allocate any mbufs, and one is needed to assign the
  8529. +              * cluster to.  The mbuf that has a cluster extension
  8530. +              * can not be used to contain data - only the cluster
  8531. +              * can contain data.
  8532. +              */
  8533. +             dst = m;
  8534. +             MGET(m, M_DONTWAIT, MT_DATA);
  8535. +             if (m == 0)
  8536. +                 return (0);
  8537. +             if (total_len >= MINCLSIZE)
  8538. +                 MCLGET(m, M_DONTWAIT);
  8539. +             m->m_len = 0;
  8540. +             dst->m_next = m;
  8541. +             amount = min(total_len, M_TRAILINGSPACE(m));
  8542. +         }
  8543. +         src = zed_ring_copy(sc, src, mtod(m, caddr_t) + m->m_len,
  8544. +             amount);
  8545. +         m->m_len += amount;
  8546. +         total_len -= amount;
  8547. +     }
  8548. +     return (m);
  8549. + }
  8550. + /*
  8551. +  * Compute the multicast address filter from the list of multicast addresses we
  8552. +  * need to listen to.
  8553. +  */
  8554. + void
  8555. + zed_getmcaf(ac, af)
  8556. +     struct arpcom *ac;
  8557. +     u_long *af;
  8558. + {
  8559. +     struct ifnet *ifp = &ac->ac_if;
  8560. +     struct ether_multi *enm;
  8561. +     register u_char *cp, c;
  8562. +     register u_long crc;
  8563. +     register int i, len;
  8564. +     struct ether_multistep step;
  8565. +     /*
  8566. +      * Set up multicast address filter by passing all multicast addresses
  8567. +      * through a crc generator, and then using the high order 6 bits as an
  8568. +      * index into the 64 bit logical address filter.  The high order bit
  8569. +      * selects the word, while the rest of the bits select the bit within
  8570. +      * the word.
  8571. +      */
  8572. +     if (ifp->if_flags & IFF_PROMISC) {
  8573. +         ifp->if_flags |= IFF_ALLMULTI;
  8574. +         af[0] = af[1] = 0xffffffff;
  8575. +         return;
  8576. +     }
  8577. +     af[0] = af[1] = 0;
  8578. +     ETHER_FIRST_MULTI(step, ac, enm);
  8579. +     while (enm != NULL) {
  8580. +         if (bcmp(enm->enm_addrlo, enm->enm_addrhi,
  8581. +             sizeof(enm->enm_addrlo)) != 0) {
  8582. +             /*
  8583. +              * We must listen to a range of multicast addresses.
  8584. +              * For now, just accept all multicasts, rather than
  8585. +              * trying to set only those filter bits needed to match
  8586. +              * the range.  (At this time, the only use of address
  8587. +              * ranges is for IP multicast routing, for which the
  8588. +              * range is big enough to require all bits set.)
  8589. +              */
  8590. +             ifp->if_flags |= IFF_ALLMULTI;
  8591. +             af[0] = af[1] = 0xffffffff;
  8592. +             return;
  8593. +         }
  8594. +         cp = enm->enm_addrlo;
  8595. +         crc = 0xffffffff;
  8596. +         for (len = sizeof(enm->enm_addrlo); --len >= 0;) {
  8597. +             c = *cp++;
  8598. +             for (i = 8; --i >= 0;) {
  8599. +                 if (((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01)) {
  8600. +                     crc <<= 1;
  8601. +                     crc ^= 0x04c11db6 | 1;
  8602. +                 } else
  8603. +                     crc <<= 1;
  8604. +                 c >>= 1;
  8605. +             }
  8606. +         }
  8607. +         /* Just want the 6 most significant bits. */
  8608. +         crc >>= 26;
  8609. +         /* Turn on the corresponding bit in the filter. */
  8610. +         af[crc >> 5] |= 1 << ((crc & 0x1f) ^ 0);
  8611. +         ETHER_NEXT_MULTI(step, enm);
  8612. +     }
  8613. +     ifp->if_flags &= ~IFF_ALLMULTI;
  8614. + }
  8615. + /*
  8616. +  * Copy packet from mbuf to the board memory
  8617. +  *
  8618. +  * Currently uses an extra buffer/extra memory copy,
  8619. +  * unless the whole packet fits in one mbuf.
  8620. +  *
  8621. +  */
  8622. + u_short
  8623. + zed_put(sc, m, buf)
  8624. +     struct zed_softc *sc;
  8625. +     struct mbuf *m;
  8626. +     caddr_t buf;
  8627. + {
  8628. +     u_char *data, savebyte[2];
  8629. +     int len, wantbyte;
  8630. +     u_short totlen;
  8631. +     totlen = wantbyte = 0;
  8632. +     for (; m != 0; m = m->m_next) {
  8633. +         data = mtod(m, u_char *);
  8634. +         len = m->m_len;
  8635. +         totlen += len;
  8636. +         if (len > 0) {
  8637. +             /* Finish the last word. */
  8638. +             if (wantbyte) {
  8639. +                 savebyte[1] = *data;
  8640. +                 word_copy(savebyte, buf, 2);
  8641. +                 buf += 2;
  8642. +                 data++;
  8643. +                 len--;
  8644. +                 wantbyte = 0;
  8645. +             }
  8646. +             /* Output contiguous words. */
  8647. +             if (len > 1) {
  8648. +                 word_copy(data, buf, len);
  8649. +                 buf += len & ~1;
  8650. +                 data += len & ~1;
  8651. +                 len &= 1;
  8652. +             }
  8653. +             /* Save last byte, if necessary. */
  8654. +             if (len == 1) {
  8655. +                 savebyte[0] = *data;
  8656. +                 wantbyte = 1;
  8657. +             }
  8658. +         }
  8659. +     }
  8660. +     if (wantbyte) {
  8661. +         savebyte[1] = 0;
  8662. +         word_copy(savebyte, buf, 2);
  8663. +         buf += 2;
  8664. +     }
  8665. +     return (totlen);
  8666. + }
  8667. *** /dev/null
  8668. --- NetBSD/src/sys/arch/amiga/dev/if_zedreg.h
  8669. ***************
  8670. *** 0 ****
  8671. --- 1,43 ----
  8672. + /*    $NetBSD: if_edreg.h,v 1.4 1995/05/08 02:40:54 chopps Exp $    */
  8673. + /*
  8674. +  * Vendor types
  8675. +  */
  8676. + #define    ED_VENDOR_HYDRA        0x03    /* Hydra Systems */
  8677. + /*
  8678. +  * Compile-time config flags
  8679. +  */
  8680. + /*
  8681. +  * This sets the default for enabling/disablng the tranceiver.
  8682. +  */
  8683. + #define ED_FLAGS_DISABLE_TRANCEIVER    0x0001
  8684. + /*
  8685. +  * This forces the board to be used in 8/16-bit mode even if it autoconfigs
  8686. +  * differently.
  8687. +  */
  8688. + #define ED_FLAGS_FORCE_8BIT_MODE    0x0002
  8689. + #define ED_FLAGS_FORCE_16BIT_MODE    0x0004
  8690. + /*
  8691. +  * This disables the use of double transmit buffers.
  8692. +  */
  8693. + #define ED_FLAGS_NO_MULTI_BUFFERING    0x0008
  8694. + /*
  8695. +  * This forces all operations with the NIC memory to use Programmed I/O (i.e.
  8696. +  * not via shared memory).
  8697. +  */
  8698. + #define ED_FLAGS_FORCE_PIO        0x0010
  8699. + /*
  8700. +  *        Definitions for Hydra Systems boards
  8701. +  */
  8702. + #define    HYDRA_ADDRPROM    0xffc0
  8703. + #define    HYDRA_NIC_BASE    0xffe1
  8704. + /*
  8705. +  *        Definitions for ASDG LANRover boards
  8706. +  */
  8707. + #define ASDG_ADDRPROM    0xff
  8708. + #define ASDG_NIC_BASE    0x1
  8709. *** /dev/null
  8710. --- NetBSD/src/sys/arch/amiga/dev/if_zle.c
  8711. ***************
  8712. *** 0 ****
  8713. --- 1,962 ----
  8714. + /*    $NetBSD: if_le.c,v 1.14 1995/07/02 00:16:06 mycroft Exp $    */
  8715. + /*
  8716. +  * Copyright (c) 1982, 1990 The Regents of the University of California.
  8717. +  * All rights reserved.
  8718. +  *
  8719. +  * Redistribution and use in source and binary forms, with or without
  8720. +  * modification, are permitted provided that the following conditions
  8721. +  * are met:
  8722. +  * 1. Redistributions of source code must retain the above copyright
  8723. +  *    notice, this list of conditions and the following disclaimer.
  8724. +  * 2. Redistributions in binary form must reproduce the above copyright
  8725. +  *    notice, this list of conditions and the following disclaimer in the
  8726. +  *    documentation and/or other materials provided with the distribution.
  8727. +  * 3. All advertising materials mentioning features or use of this software
  8728. +  *    must display the following acknowledgement:
  8729. +  *    This product includes software developed by the University of
  8730. +  *    California, Berkeley and its contributors.
  8731. +  * 4. Neither the name of the University nor the names of its contributors
  8732. +  *    may be used to endorse or promote products derived from this software
  8733. +  *    without specific prior written permission.
  8734. +  *
  8735. +  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  8736. +  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  8737. +  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  8738. +  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  8739. +  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  8740. +  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  8741. +  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  8742. +  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  8743. +  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  8744. +  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  8745. +  * SUCH DAMAGE.
  8746. +  *
  8747. +  *    @(#)if_le.c    7.6 (Berkeley) 5/8/91
  8748. +  */
  8749. + #include "le.h"
  8750. + #if NLE > 0
  8751. + #include "bpfilter.h"
  8752. + /*
  8753. +  * AMD 7990 LANCE
  8754. +  *
  8755. +  * This driver will generate and accept tailer encapsulated packets even
  8756. +  * though it buys us nothing.  The motivation was to avoid incompatibilities
  8757. +  * with VAXen, SUNs, and others that handle and benefit from them.
  8758. +  * This reasoning is dubious.
  8759. +  */
  8760. + #include <sys/param.h>
  8761. + #include <sys/systm.h>
  8762. + #include <sys/mbuf.h>
  8763. + #include <sys/buf.h>
  8764. + #include <sys/protosw.h>
  8765. + #include <sys/socket.h>
  8766. + #include <sys/syslog.h>
  8767. + #include <sys/ioctl.h>
  8768. + #include <sys/errno.h>
  8769. + #include <sys/device.h>
  8770. + #include <net/if.h>
  8771. + #include <net/netisr.h>
  8772. + #include <net/route.h>
  8773. + #ifdef INET
  8774. + #include <netinet/in.h>
  8775. + #include <netinet/in_systm.h>
  8776. + #include <netinet/in_var.h>
  8777. + #include <netinet/ip.h>
  8778. + #include <netinet/if_ether.h>
  8779. + #endif
  8780. + #ifdef NS
  8781. + #include <netns/ns.h>
  8782. + #include <netns/ns_if.h>
  8783. + #endif
  8784. + #include <machine/cpu.h>
  8785. + #include <machine/mtpr.h>
  8786. + #include <amiga/amiga/device.h>
  8787. + #include <amiga/amiga/isr.h>
  8788. + #include <amiga/dev/zbusvar.h>
  8789. + #include <amiga/dev/if_lereg.h>
  8790. + /*
  8791. +  * Ethernet software status per interface.
  8792. +  *
  8793. +  * Each interface is referenced by a network interface structure,
  8794. +  * le_if, which the routing code uses to locate the interface.
  8795. +  * This structure contains the output queue for the interface, its address, ...
  8796. +  */
  8797. + struct    le_softc {
  8798. +     struct    isr sc_isr;
  8799. +     struct    arpcom sc_ac;    /* common Ethernet structures */
  8800. + #define    sc_if    sc_ac.ac_if    /* network-visible interface */
  8801. + #define    sc_addr    sc_ac.ac_enaddr    /* hardware Ethernet address */
  8802. +     void    *sc_base;    /* base address of board */
  8803. +     struct    lereg1 *sc_r1;    /* LANCE registers */
  8804. +     struct    lereg2 *sc_r2;    /* dual-port RAM */
  8805. +     int    sc_rmd;        /* predicted next rmd to process */
  8806. +     int    sc_tmd;        /* next tmd to use */
  8807. +     int    sc_no_td;    /* number of tmds in use */
  8808. +     int    sc_runt;
  8809. +     int    sc_jab;
  8810. +     int    sc_merr;
  8811. +     int    sc_babl;
  8812. +     int    sc_cerr;
  8813. +     int    sc_miss;
  8814. +     int    sc_xint;
  8815. +     int    sc_xown;
  8816. +     int    sc_uflo;
  8817. +     int    sc_rxlen;
  8818. +     int    sc_rxoff;
  8819. +     int    sc_txoff;
  8820. +     int    sc_busy;
  8821. +     short    sc_iflags;
  8822. + #if NBPFILTER > 0
  8823. +     caddr_t sc_bpf;
  8824. + #endif
  8825. + } le_softc[NLE];
  8826. + #if NBPFILTER > 0
  8827. + #include <net/bpf.h>
  8828. + #include <net/bpfdesc.h>
  8829. + #endif
  8830. + /* offsets for:       ID,   REGS,    MEM */
  8831. + int    lestd[] = { 0, 0x4000, 0x8000 };
  8832. + /* console error messages */
  8833. + int    ledebug = 0;
  8834. + int leioctl __P((struct ifnet *, u_long, caddr_t));
  8835. + int leintr __P((struct le_softc *));
  8836. + void lestart __P((struct ifnet *));
  8837. + void leinit __P((int));
  8838. + struct    mbuf *leget();
  8839. + extern    struct ifnet loif;
  8840. + void leattach __P((struct device *, struct device *, void *));
  8841. + int lematch __P((struct device *, struct cfdata *, void *args));
  8842. + struct cfdriver lecd = {
  8843. +     NULL, "le", (cfmatch_t)lematch, leattach, DV_IFNET,
  8844. +     sizeof(struct le_softc), NULL, 0};
  8845. + int
  8846. + lematch(pdp, cfp, auxp)
  8847. +     struct device *pdp;
  8848. +     struct cfdata *cfp;
  8849. +     void *auxp;
  8850. + {
  8851. +     struct zbus_args *zap;
  8852. +     zap = (struct zbus_args *)auxp;
  8853. +     /* Commodore ethernet card */
  8854. +     if ( zap->manid == 514 && zap->prodid == 112)
  8855. +         return(1);
  8856. +     /* Ameristar ethernet card */
  8857. +     if ( zap->manid == 1053 && zap->prodid == 1)
  8858. +         return(1);
  8859. +     return (0);
  8860. + }
  8861. + /*
  8862. +  * Interface exists: make available by filling in network interface
  8863. +  * record.  System will initialize the interface when it is ready
  8864. +  * to accept packets.
  8865. +  */
  8866. + void
  8867. + leattach(pdp, dp, auxp)
  8868. +     struct device *pdp, *dp;
  8869. +     void *auxp;
  8870. + {
  8871. +     register struct lereg0 *ler0;
  8872. +     register struct lereg2 *ler2;
  8873. +     struct zbus_args *zap;
  8874. +     struct lereg2 *lemem = (struct lereg2 *) 0x8000;
  8875. +     struct le_softc *le = &le_softc[dp->dv_unit];
  8876. +     struct ifnet *ifp = &le->sc_if;
  8877. +     char *cp;
  8878. +     int i;
  8879. +     unsigned long ser;
  8880. +     int s = splhigh ();
  8881. +     zap =(struct zbus_args *)auxp;
  8882. +     /*
  8883. +      * Make config msgs look nicer.
  8884. +      */
  8885. +     printf("\n");
  8886. +     ler0 = le->sc_base = zap->va;
  8887. +     le->sc_r1 = (struct lereg1 *)(lestd[1] + (int)zap->va);
  8888. +     ler2 = le->sc_r2 = (struct lereg2 *)(lestd[2] + (int)zap->va);
  8889. +     /*
  8890. +      * Manufacturer decides the 3 first bytes, i.e. ethernet vendor ID.
  8891. +      */
  8892. +     if ( zap->manid == 514 && zap->prodid == 112) {
  8893. +         /* Commodore 2065 */
  8894. +         le->sc_addr[0] = 0x00;
  8895. +         le->sc_addr[1] = 0x80;
  8896. +         le->sc_addr[2] = 0x10;
  8897. +     }
  8898. +     if ( zap->manid == 1053 && zap->prodid == 1) {
  8899. +         le->sc_addr[0] = 0x00;
  8900. +         le->sc_addr[1] = 0x00;
  8901. +         le->sc_addr[2] = 0x9f;
  8902. +     }
  8903. +     /*
  8904. +      * Serial number for board is used as host ID.
  8905. +      */
  8906. +     ser = (unsigned long) zap->serno;
  8907. +     le->sc_addr[3] = (ser >> 16) & 0xff;
  8908. +     le->sc_addr[4] = (ser >>  8) & 0xff;
  8909. +     le->sc_addr[5] = (ser      ) & 0xff;
  8910. + #ifdef LE_USE_16K
  8911. +     printf("le%d: hardware address %s 16K\n",
  8912. + #else
  8913. +     printf("le%d: hardware address %s 32K\n",
  8914. + #endif
  8915. +     dp->dv_unit, ether_sprintf(le->sc_addr));
  8916. +     /*
  8917. +      * Setup for transmit/receive
  8918. +      */
  8919. +     ler2->ler2_mode = LE_MODE;
  8920. +     ler2->ler2_padr[0] = le->sc_addr[1];
  8921. +     ler2->ler2_padr[1] = le->sc_addr[0];
  8922. +     ler2->ler2_padr[2] = le->sc_addr[3];
  8923. +     ler2->ler2_padr[3] = le->sc_addr[2];
  8924. +     ler2->ler2_padr[4] = le->sc_addr[5];
  8925. +     ler2->ler2_padr[5] = le->sc_addr[4];
  8926. +     ler2->ler2_ladrf0 = 0;
  8927. +     ler2->ler2_ladrf1 = 0;
  8928. +     ler2->ler2_rlen = LE_RLEN;
  8929. +     ler2->ler2_rdra = (int)lemem->ler2_rmd;
  8930. +     ler2->ler2_tlen = LE_TLEN;
  8931. +     ler2->ler2_tdra = (int)lemem->ler2_tmd;
  8932. +     splx (s);
  8933. +     ifp->if_unit = dp->dv_unit;
  8934. +     ifp->if_name = "le";
  8935. +     ifp->if_mtu = ETHERMTU;
  8936. +     ifp->if_ioctl = leioctl;
  8937. +     ifp->if_output = ether_output;
  8938. +     ifp->if_start = lestart;
  8939. +     ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX;
  8940. + #if NBPFILTER > 0
  8941. +     bpfattach(&le->sc_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header));
  8942. + #endif
  8943. +     if_attach(ifp);
  8944. +     ether_ifattach(ifp);
  8945. +     le->sc_isr.isr_intr = leintr;
  8946. +     le->sc_isr.isr_arg = le;
  8947. +     le->sc_isr.isr_ipl = 2;
  8948. +     add_isr (&le->sc_isr);
  8949. +     le->sc_isr.isr_intr = leintr;
  8950. +     le->sc_isr.isr_arg = le;
  8951. +     le->sc_isr.isr_ipl = 2;
  8952. +     add_isr (&le->sc_isr);
  8953. +     return;
  8954. + }
  8955. + ledrinit(ler2)
  8956. +     register struct lereg2 *ler2;
  8957. + {
  8958. +     register struct lereg2 *lemem = (struct lereg2 *) 0x8000;
  8959. +     register int i;
  8960. +     for (i = 0; i < LERBUF; i++) {
  8961. +         ler2->ler2_rmd[i].rmd0 = (int)lemem->ler2_rbuf[i];
  8962. +         ler2->ler2_rmd[i].rmd1 = LE_OWN;
  8963. +         ler2->ler2_rmd[i].rmd2 = -LEMTU;
  8964. +         ler2->ler2_rmd[i].rmd3 = 0;
  8965. +     }
  8966. +     for (i = 0; i < LETBUF; i++) {
  8967. +         ler2->ler2_tmd[i].tmd0 = (int)lemem->ler2_tbuf[i];
  8968. +         ler2->ler2_tmd[i].tmd1 = 0;
  8969. +         ler2->ler2_tmd[i].tmd2 = 0;
  8970. +         ler2->ler2_tmd[i].tmd3 = 0;
  8971. +     }
  8972. + }
  8973. + void
  8974. + lereset(unit)
  8975. +     register int unit;
  8976. + {
  8977. +     register struct le_softc *le = &le_softc[unit];
  8978. +     register struct lereg1 *ler1 = le->sc_r1;
  8979. +     /*
  8980. +      * This structure is referenced from the CARDS/LANCE point of
  8981. +      * view, thus the 0x8000 address which is the buffer RAM area of
  8982. +      * the Commodore and Ameristar cards. This pointer is manipulated
  8983. +      * with the LANCE's view of memory and NOT the Amiga's. FYI.
  8984. +      */
  8985. +     register struct lereg2 *lemem = (struct lereg2 *) 0x8000;
  8986. +     register int timo = 100000;
  8987. +     register int stat;
  8988. + #ifdef lint
  8989. +     stat = unit;
  8990. + #endif
  8991. + #if NBPFILTER > 0
  8992. +     if (le->sc_if.if_flags & IFF_PROMISC)
  8993. +         /* set the promiscuous bit */
  8994. +         le->sc_r2->ler2_mode = LE_MODE|0x8000;
  8995. +     else
  8996. +         le->sc_r2->ler2_mode = LE_MODE;
  8997. + #endif
  8998. +      ler1->ler1_rap =  LE_CSR0;
  8999. +      ler1->ler1_rdp =  LE_STOP;
  9000. +      ledrinit(le->sc_r2);
  9001. +      le->sc_rmd = le->sc_tmd = le->sc_no_td = 0;
  9002. +      ler1->ler1_rap =  LE_CSR1;
  9003. +      ler1->ler1_rdp =  (int)&lemem->ler2_mode;
  9004. +      ler1->ler1_rap =  LE_CSR2;
  9005. +      ler1->ler1_rdp =  0;
  9006. +      ler1->ler1_rap =  LE_CSR0;
  9007. +      ler1->ler1_rdp =  LE_INIT;
  9008. +     do {
  9009. +         if (--timo == 0) {
  9010. +             printf("le%d: init timeout, stat = 0x%x\n",
  9011. +                    unit, stat);
  9012. +             break;
  9013. +         }
  9014. +          stat =  ler1->ler1_rdp;
  9015. +     } while ((stat & LE_IDON) == 0);
  9016. +      ler1->ler1_rdp =  LE_STOP;
  9017. +      ler1->ler1_rap =  LE_CSR3;
  9018. +      ler1->ler1_rdp =  LE_BSWP;
  9019. +      ler1->ler1_rap =  LE_CSR0;
  9020. +      ler1->ler1_rdp =  LE_STRT | LE_INEA;
  9021. +      le->sc_if.if_flags &= ~IFF_OACTIVE;
  9022. +     return;
  9023. + }
  9024. + /*
  9025. +  * Initialization of interface
  9026. +  */
  9027. + void
  9028. + leinit(unit)
  9029. +     int unit;
  9030. + {
  9031. +     struct le_softc *le = &le_softc[unit];
  9032. +     register struct ifnet *ifp = &le->sc_if;
  9033. +     int s;
  9034. +     if ((ifp->if_flags & IFF_RUNNING) == 0) {
  9035. +         s = splimp();
  9036. +         ifp->if_flags |= IFF_RUNNING;
  9037. +         lereset(unit);
  9038. +             (void) lestart(ifp);
  9039. +         splx(s);
  9040. +     }
  9041. +     return;
  9042. + }
  9043. + #define LENEXTTMP \
  9044. +     if (++bix == LETBUF) bix = 0, tmd = le->sc_r2->ler2_tmd; else ++tmd
  9045. + /*
  9046. +  * Start output on interface.  Get another datagram to send
  9047. +  * off of the interface queue, and copy it to the interface
  9048. +  * before starting the output.
  9049. +  */
  9050. + void
  9051. + lestart(ifp)
  9052. +     struct ifnet *ifp;
  9053. + {
  9054. +     register struct le_softc *le = &le_softc[ifp->if_unit];
  9055. +     register int bix;
  9056. +     register struct letmd *tmd;
  9057. +     register struct mbuf *m;
  9058. +     int len;
  9059. +     if ((le->sc_if.if_flags & IFF_RUNNING) == 0)
  9060. +         return;
  9061. +     bix = le->sc_tmd;
  9062. +     tmd = &le->sc_r2->ler2_tmd[bix];
  9063. +     for (;;) {
  9064. +         if (le->sc_no_td >= LETBUF) {
  9065. +             le->sc_if.if_flags |= IFF_OACTIVE;
  9066. +             break;
  9067. +         }
  9068. +         IF_DEQUEUE(&le->sc_if.if_snd, m);
  9069. +         if (m == 0)
  9070. +             break;
  9071. +         ++le->sc_no_td;
  9072. +         len = leput(le->sc_r2->ler2_tbuf[bix], m);
  9073. + #if NBPFILTER > 0
  9074. +         /*
  9075. +          * If bpf is listening on this interface, let it
  9076. +          * see the packet before we commit it to the wire.
  9077. +          */
  9078. +         if (le->sc_bpf)
  9079. +                     bpf_tap(le->sc_bpf, le->sc_r2->ler2_tbuf[bix], len);
  9080. + #endif
  9081. +         tmd->tmd3 = 0;
  9082. +         tmd->tmd2 = -len;
  9083. +         tmd->tmd1 = LE_OWN | LE_STP | LE_ENP;
  9084. +         LENEXTTMP;
  9085. +     }
  9086. +     le->sc_tmd = bix;
  9087. + }
  9088. + int
  9089. + leintr(le)
  9090. +     struct le_softc *le;
  9091. + {
  9092. + #if 0
  9093. +     register struct le_softc *le = &le_softc[unit];
  9094. + #else
  9095. +     int unit = le->sc_if.if_unit;
  9096. + #endif
  9097. +     register struct lereg1 *ler1;
  9098. +     register int stat;
  9099. +     /* if not even initialized, don't do anything further.. */
  9100. +     if (! le->sc_base)
  9101. +       return 0;
  9102. +     ler1 = le->sc_r1;
  9103. +     stat =  ler1->ler1_rdp;
  9104. +     if (! (stat & LE_INTR))
  9105. +       return 0;
  9106. +     if (stat & LE_SERR) {
  9107. +         leerror(unit, stat);
  9108. +         if (stat & LE_MERR) {
  9109. +             le->sc_merr++;
  9110. +             lereset(unit);
  9111. +             return(1);
  9112. +         }
  9113. +         if (stat & LE_BABL)
  9114. +             le->sc_babl++;
  9115. +         if (stat & LE_CERR)
  9116. +             le->sc_cerr++;
  9117. +         if (stat & LE_MISS)
  9118. +             le->sc_miss++;
  9119. +          ler1->ler1_rdp =  LE_BABL|LE_CERR|LE_MISS|LE_INEA;
  9120. +     }
  9121. +     if ((stat & LE_RXON) == 0) {
  9122. +         le->sc_rxoff++;
  9123. +         lereset(unit);
  9124. +         return(1);
  9125. +     }
  9126. +     if ((stat & LE_TXON) == 0) {
  9127. +         le->sc_txoff++;
  9128. +         lereset(unit);
  9129. +         return(1);
  9130. +     }
  9131. +     if (stat & LE_RINT) {
  9132. +         /* interrupt is cleared in lerint */
  9133. +         lerint(unit);
  9134. +     }
  9135. +     if (stat & LE_TINT) {
  9136. +          ler1->ler1_rdp =  LE_TINT|LE_INEA;
  9137. +         lexint(unit);
  9138. +     }
  9139. +     return(1);
  9140. + }
  9141. + /*
  9142. +  * Ethernet interface transmitter interrupt.
  9143. +  * Start another output if more data to send.
  9144. +  */
  9145. + lexint(unit)
  9146. +     register int unit;
  9147. + {
  9148. +     register struct le_softc *le = &le_softc[unit];
  9149. +     register int bix = (le->sc_tmd - le->sc_no_td + LETBUF) % LETBUF;
  9150. +     register struct letmd *tmd = &le->sc_r2->ler2_tmd[bix];
  9151. +     if ((le->sc_if.if_flags & IFF_OACTIVE) == 0) {
  9152. +         le->sc_xint++;
  9153. +         return;
  9154. +     }
  9155. +     if (tmd->tmd1 & LE_OWN) {
  9156. + printf("le%d: extra xint\n", unit);
  9157. +         le->sc_xown++;
  9158. +         return;
  9159. +     }
  9160. +     le->sc_if.if_flags &= ~IFF_OACTIVE;
  9161. +     do {
  9162. +         if (le->sc_no_td <= 0)
  9163. +             break;
  9164. +         --le->sc_no_td;
  9165. +         if (tmd->tmd1 & LE_ERR) {
  9166. + err:
  9167. + printf("le%d: xint error\n", unit);
  9168. +             lexerror(unit);
  9169. +             le->sc_if.if_oerrors++;
  9170. +             if (tmd->tmd3 & (LE_TBUFF|LE_UFLO)) {
  9171. +                 le->sc_uflo++;
  9172. +                 lereset(unit);
  9173. +                 return;
  9174. +             }
  9175. +             else if (tmd->tmd3 & LE_LCOL)
  9176. +                 le->sc_if.if_collisions++;
  9177. +             else if (tmd->tmd3 & LE_RTRY)
  9178. +                 le->sc_if.if_collisions += 16;
  9179. +         }
  9180. +         else if (tmd->tmd3 & LE_TBUFF)
  9181. +             /* XXX documentation says BUFF not included in ERR */
  9182. +             goto err;
  9183. +         else if (tmd->tmd1 & LE_ONE)
  9184. +             le->sc_if.if_collisions++;
  9185. +         else if (tmd->tmd1 & LE_MORE)
  9186. +             /* what is the real number? */
  9187. +             le->sc_if.if_collisions += 2;
  9188. +         else
  9189. +             le->sc_if.if_opackets++;
  9190. +         LENEXTTMP;
  9191. +     } while ((tmd->tmd1 & LE_OWN) == 0);
  9192. +     (void) lestart(&le->sc_if);
  9193. + }
  9194. + #define    LENEXTRMP \
  9195. +     if (++bix == LERBUF) bix = 0, rmd = le->sc_r2->ler2_rmd; else ++rmd
  9196. + /*
  9197. +  * Ethernet interface receiver interrupt.
  9198. +  * If input error just drop packet.
  9199. +  * Decapsulate packet based on type and pass to type specific
  9200. +  * higher-level input routine.
  9201. +  */
  9202. + lerint(unit)
  9203. +     int unit;
  9204. + {
  9205. +     register struct le_softc *le = &le_softc[unit];
  9206. +     register int bix = le->sc_rmd;
  9207. +     register struct lermd *rmd = &le->sc_r2->ler2_rmd[bix];
  9208. +     /*
  9209. +      * Out of sync with hardware, should never happen?
  9210. +      */
  9211. +     if (rmd->rmd1 & LE_OWN) {
  9212. +          le->sc_r1->ler1_rdp =  LE_RINT|LE_INEA;
  9213. +         return;
  9214. +     }
  9215. +     /*
  9216. +      * Process all buffers with valid data
  9217. +      */
  9218. +     while ((rmd->rmd1 & LE_OWN) == 0) {
  9219. +         int len = rmd->rmd3;
  9220. +         /* Clear interrupt to avoid race condition */
  9221. +          le->sc_r1->ler1_rdp =  LE_RINT|LE_INEA;
  9222. +         if (rmd->rmd1 & LE_ERR) {
  9223. +             le->sc_rmd = bix;
  9224. +             lererror(unit, "bad packet");
  9225. +             le->sc_if.if_ierrors++;
  9226. +         } else if ((rmd->rmd1 & (LE_STP|LE_ENP)) != (LE_STP|LE_ENP)) {
  9227. +             /*
  9228. +              * Find the end of the packet so we can see how long
  9229. +              * it was.  We still throw it away.
  9230. +              */
  9231. +             do {
  9232. +                     le->sc_r1->ler1_rdp = LE_RINT|LE_INEA;
  9233. +                 rmd->rmd3 = 0;
  9234. +                 rmd->rmd1 = LE_OWN;
  9235. +                 LENEXTRMP;
  9236. +             } while (!(rmd->rmd1 & (LE_OWN|LE_ERR|LE_STP|LE_ENP)));
  9237. +             le->sc_rmd = bix;
  9238. +             lererror(unit, "chained buffer");
  9239. +             le->sc_rxlen++;
  9240. +             /*
  9241. +              * If search terminated without successful completion
  9242. +              * we reset the hardware (conservative).
  9243. +              */
  9244. +             if ((rmd->rmd1 & (LE_OWN|LE_ERR|LE_STP|LE_ENP)) != LE_ENP) {
  9245. +                 lereset(unit);
  9246. +                 return;
  9247. +             }
  9248. +         } else
  9249. +             leread(unit, le->sc_r2->ler2_rbuf[bix], len);
  9250. +         rmd->rmd3 = 0;
  9251. +         rmd->rmd1 = LE_OWN;
  9252. +         LENEXTRMP;
  9253. +     }
  9254. +     le->sc_rmd = bix;
  9255. + }
  9256. + leread(unit, buf, len)
  9257. +     int unit;
  9258. +     char *buf;
  9259. +     int len;
  9260. + {
  9261. +     register struct le_softc *le = &le_softc[unit];
  9262. +     register struct ether_header *et;
  9263. +         struct mbuf *m;
  9264. +     int off, resid;
  9265. +     le->sc_if.if_ipackets++;
  9266. +     et = (struct ether_header *)buf;
  9267. +     et->ether_type = ntohs((u_short)et->ether_type);
  9268. +     /* adjust input length to account for header and CRC */
  9269. +     len = len - sizeof(struct ether_header) - 4;
  9270. + #define    ledataaddr(et, off, type)    ((type)(((caddr_t)((et)+1)+(off))))
  9271. +     if (et->ether_type >= ETHERTYPE_TRAIL &&
  9272. +         et->ether_type < ETHERTYPE_TRAIL+ETHERTYPE_NTRAILER) {
  9273. +         off = (et->ether_type - ETHERTYPE_TRAIL) * 512;
  9274. +         if (off >= ETHERMTU)
  9275. +             return;        /* sanity */
  9276. +         et->ether_type = ntohs(*ledataaddr(et, off, u_short *));
  9277. +         resid = ntohs(*(ledataaddr(et, off+2, u_short *)));
  9278. +         if (off + resid > len)
  9279. +             return;        /* sanity */
  9280. +         len = off + resid;
  9281. +     } else
  9282. +         off = 0;
  9283. +     if (len <= 0) {
  9284. +         if (ledebug)
  9285. +             log(LOG_WARNING,
  9286. +                 "le%d: ierror(runt packet): from %s: len=%d\n",
  9287. +                 unit, ether_sprintf(et->ether_shost), len);
  9288. +         le->sc_runt++;
  9289. +         le->sc_if.if_ierrors++;
  9290. +         return;
  9291. +     }
  9292. + #if NBPFILTER > 0
  9293. +     /*
  9294. +      * Check if there's a bpf filter listening on this interface.
  9295. +      * If so, hand off the raw packet to bpf, which must deal with
  9296. +      * trailers in its own way.
  9297. +      */
  9298. +     if (le->sc_bpf) {
  9299. +         bpf_tap(le->sc_bpf, buf, len + sizeof(struct ether_header));
  9300. +         /*
  9301. +          * Note that the interface cannot be in promiscuous mode if
  9302. +          * there are no bpf listeners.  And if we are in promiscuous
  9303. +          * mode, we have to check if this packet is really ours.
  9304. +          *
  9305. +          * XXX This test does not support multicasts.
  9306. +          */
  9307. +         if ((le->sc_if.if_flags & IFF_PROMISC)
  9308. +             && bcmp(et->ether_dhost, le->sc_addr, 
  9309. +                 sizeof(et->ether_dhost)) != 0
  9310. +             && bcmp(et->ether_dhost, etherbroadcastaddr, 
  9311. +                 sizeof(et->ether_dhost)) != 0)
  9312. +             return;
  9313. +     }
  9314. + #endif
  9315. +     /*
  9316. +      * Pull packet off interface.  Off is nonzero if packet
  9317. +      * has trailing header; leget will then force this header
  9318. +      * information to be at the front, but we still have to drop
  9319. +      * the type and length which are at the front of any trailer data.
  9320. +      */
  9321. +     m = leget(buf, len, off, &le->sc_if);
  9322. +     if (m == 0)
  9323. +         return;
  9324. +     ether_input(&le->sc_if, et, m);
  9325. + }
  9326. + /*
  9327. +  * Routine to copy from mbuf chain to transmit
  9328. +  * buffer in board local memory.
  9329. +  */
  9330. + leput(lebuf, m)
  9331. +     register char *lebuf;
  9332. +     register struct mbuf *m;
  9333. + {
  9334. +     register struct mbuf *mp;
  9335. +     register int len, tlen = 0;
  9336. +     for (mp = m; mp; mp = mp->m_next) {
  9337. +         len = mp->m_len;
  9338. +         if (len == 0)
  9339. +             continue;
  9340. +         tlen += len;
  9341. +         bcopy(mtod(mp, char *), lebuf, len);
  9342. +         lebuf += len;
  9343. +     }
  9344. +     m_freem(m);
  9345. +     if (tlen < LEMINSIZE) {
  9346. +         bzero(lebuf, LEMINSIZE - tlen);
  9347. +         tlen = LEMINSIZE;
  9348. +     }
  9349. +     return(tlen);
  9350. + }
  9351. + /*
  9352. +  * Routine to copy from board local memory into mbufs.
  9353. +  */
  9354. + struct mbuf *
  9355. + leget(lebuf, totlen, off0, ifp)
  9356. +     char *lebuf;
  9357. +     int totlen, off0;
  9358. +     struct ifnet *ifp;
  9359. + {
  9360. +     register struct mbuf *m;
  9361. +     struct mbuf *top = 0, **mp = ⊤
  9362. +     register int off = off0, len;
  9363. +     register char *cp;
  9364. +     char *epkt;
  9365. +     lebuf += sizeof (struct ether_header);
  9366. +     cp = lebuf;
  9367. +     epkt = cp + totlen;
  9368. +     if (off) {
  9369. +         cp += off + 2 * sizeof(u_short);
  9370. +         totlen -= 2 * sizeof(u_short);
  9371. +     }
  9372. +     MGETHDR(m, M_DONTWAIT, MT_DATA);
  9373. +     if (m == 0)
  9374. +         return (0);
  9375. +     m->m_pkthdr.rcvif = ifp;
  9376. +     m->m_pkthdr.len = totlen;
  9377. +     m->m_len = MHLEN;
  9378. +     while (totlen > 0) {
  9379. +         if (top) {
  9380. +             MGET(m, M_DONTWAIT, MT_DATA);
  9381. +             if (m == 0) {
  9382. +                 m_freem(top);
  9383. +                 return (0);
  9384. +             }
  9385. +             m->m_len = MLEN;
  9386. +         }
  9387. +         len = min(totlen, epkt - cp);
  9388. +         if (len >= MINCLSIZE) {
  9389. +             MCLGET(m, M_DONTWAIT);
  9390. +             if (m->m_flags & M_EXT)
  9391. +                 m->m_len = len = min(len, MCLBYTES);
  9392. +             else
  9393. +                 len = m->m_len;
  9394. +         } else {
  9395. +             /*
  9396. +              * Place initial small packet/header at end of mbuf.
  9397. +              */
  9398. +             if (len < m->m_len) {
  9399. +                 if (top == 0 && len + max_linkhdr <= m->m_len)
  9400. +                     m->m_data += max_linkhdr;
  9401. +                 m->m_len = len;
  9402. +             } else
  9403. +                 len = m->m_len;
  9404. +         }
  9405. +         bcopy(cp, mtod(m, caddr_t), (unsigned)len);
  9406. +         cp += len;
  9407. +         *mp = m;
  9408. +         mp = &m->m_next;
  9409. +         totlen -= len;
  9410. +         if (cp == epkt)
  9411. +             cp = lebuf;
  9412. +     }
  9413. +     return (top);
  9414. + }
  9415. + /*
  9416. +  * Process an ioctl request.
  9417. +  */
  9418. + int
  9419. + leioctl(ifp, cmd, data)
  9420. +     register struct ifnet *ifp;
  9421. +     u_long cmd;
  9422. +     caddr_t data;
  9423. + {
  9424. +     register struct ifaddr *ifa = (struct ifaddr *)data;
  9425. +     struct le_softc *le = &le_softc[ifp->if_unit];
  9426. +     struct lereg1 *ler1 = le->sc_r1;
  9427. +     int s = splimp(), error = 0;
  9428. +     switch (cmd) {
  9429. +     case SIOCSIFADDR:
  9430. +         ifp->if_flags |= IFF_UP;
  9431. +         switch (ifa->ifa_addr->sa_family) {
  9432. + #ifdef INET
  9433. +         case AF_INET:
  9434. +             leinit(ifp->if_unit);
  9435. +             arp_ifinit(&le->sc_ac, ifa);
  9436. +             break;
  9437. + #endif
  9438. + #ifdef NS
  9439. +         case AF_NS:
  9440. +             {
  9441. +             register struct ns_addr *ina = &(IA_SNS(ifa)->sns_addr);
  9442. +             if (ns_nullhost(*ina))
  9443. +                 ina->x_host = *(union ns_host *)(le->sc_addr);
  9444. +             else {
  9445. +                 /* 
  9446. +                  * The manual says we can't change the address 
  9447. +                  * while the receiver is armed,
  9448. +                  * so reset everything
  9449. +                  */
  9450. +                 ifp->if_flags &= ~IFF_RUNNING; 
  9451. +                 bcopy((caddr_t)ina->x_host.c_host,
  9452. +                     (caddr_t)le->sc_addr, sizeof(le->sc_addr));
  9453. +             }
  9454. +             leinit(ifp->if_unit); /* does le_setaddr() */
  9455. +             break;
  9456. +             }
  9457. + #endif
  9458. +         default:
  9459. +             leinit(ifp->if_unit);
  9460. +             break;
  9461. +         }
  9462. +         break;
  9463. +     case SIOCSIFFLAGS:
  9464. +         if ((ifp->if_flags & IFF_UP) == 0 &&
  9465. +             ifp->if_flags & IFF_RUNNING) {
  9466. +              ler1->ler1_rdp =  LE_STOP;
  9467. +             ifp->if_flags &= ~IFF_RUNNING;
  9468. +         } else if (ifp->if_flags & IFF_UP && (ifp->if_flags & IFF_RUNNING) == 0)
  9469. +             leinit(ifp->if_unit);
  9470. +         /*
  9471. +          * If the state of the promiscuous bit changes, the interface
  9472. +          * must be reset to effect the change.
  9473. +          */
  9474. +         if (((ifp->if_flags ^ le->sc_iflags) & IFF_PROMISC) && (ifp->if_flags & IFF_RUNNING)) {
  9475. +             le->sc_iflags = ifp->if_flags;
  9476. +             lereset(ifp->if_unit);
  9477. +             lestart(ifp);
  9478. +         }
  9479. +         break;
  9480. +     default:
  9481. +         error = EINVAL;
  9482. +     }
  9483. +     splx(s);
  9484. +     return (error);
  9485. + }
  9486. + leerror(unit, stat)
  9487. +     int unit;
  9488. +     int stat;
  9489. + {
  9490. +     if (!ledebug)
  9491. +         return;
  9492. +     /*
  9493. +      * Not all transceivers implement heartbeat
  9494. +      * so we only log CERR once.
  9495. +      */
  9496. +     if ((stat & LE_CERR) && le_softc[unit].sc_cerr)
  9497. +         return;
  9498. +     log(LOG_WARNING,
  9499. +         "le%d: error: stat=%b\n", unit,
  9500. +         stat,
  9501. +         "\20\20ERR\17BABL\16CERR\15MISS\14MERR\13RINT\12TINT\11IDON\10INTR\07INEA\06RXON\05TXON\04TDMD\03STOP\02STRT\01INIT");
  9502. + }
  9503. + lererror(unit, msg)
  9504. +     int unit;
  9505. +     char *msg;
  9506. + {
  9507. +     register struct le_softc *le = &le_softc[unit];
  9508. +     register struct lermd *rmd;
  9509. +     int len;
  9510. +     if (!ledebug)
  9511. +         return;
  9512. +     rmd = &le->sc_r2->ler2_rmd[le->sc_rmd];
  9513. +     len = rmd->rmd3;
  9514. +     log(LOG_WARNING,
  9515. +         "le%d: ierror(%s): from %s: buf=%d, len=%d, rmd1=%b\n",
  9516. +         unit, msg,
  9517. +         len > 11 ? ether_sprintf(&le->sc_r2->ler2_rbuf[le->sc_rmd][6]) : "unknown",
  9518. +         le->sc_rmd, len,
  9519. +         rmd->rmd1,
  9520. +         "\20\20OWN\17ERR\16FRAM\15OFLO\14CRC\13RBUF\12STP\11ENP");
  9521. + }
  9522. + lexerror(unit)
  9523. +     int unit;
  9524. + {
  9525. +     register struct le_softc *le = &le_softc[unit];
  9526. +     int bix;
  9527. +     register struct letmd *tmd;
  9528. +     int len;
  9529. +     if (!ledebug)
  9530. +         return;
  9531. +     bix = (le->sc_tmd - le->sc_no_td + LETBUF) % LETBUF;
  9532. +     tmd = &le->sc_r2->ler2_tmd[bix];
  9533. +     len = -tmd->tmd2;
  9534. +     log(LOG_WARNING,
  9535. +         "le%d: oerror: to %s: buf=%d, len=%d, tmd1=%b, tmd3=%b\n",
  9536. +         unit,
  9537. +         len > 5 ? ether_sprintf(&le->sc_r2->ler2_tbuf[0][0]) : "unknown",
  9538. +         0, len,
  9539. +         tmd->tmd1,
  9540. +         "\20\20OWN\17ERR\16RES\15MORE\14ONE\13DEF\12STP\11ENP",
  9541. +         tmd->tmd3,
  9542. +         "\20\20BUFF\17UFLO\16RES\15LCOL\14LCAR\13RTRY");
  9543. + }
  9544. + #endif
  9545. *** /dev/null
  9546. --- NetBSD/src/sys/arch/amiga/dev/if_zlereg.h
  9547. ***************
  9548. *** 0 ****
  9549. --- 1,175 ----
  9550. + /*    $NetBSD: if_lereg.h,v 1.5 1994/12/28 09:25:30 chopps Exp $    */
  9551. + /*
  9552. +  * Copyright (c) 1982, 1990 The Regents of the University of California.
  9553. +  * All rights reserved.
  9554. +  *
  9555. +  * Redistribution and use in source and binary forms, with or without
  9556. +  * modification, are permitted provided that the following conditions
  9557. +  * are met:
  9558. +  * 1. Redistributions of source code must retain the above copyright
  9559. +  *    notice, this list of conditions and the following disclaimer.
  9560. +  * 2. Redistributions in binary form must reproduce the above copyright
  9561. +  *    notice, this list of conditions and the following disclaimer in the
  9562. +  *    documentation and/or other materials provided with the distribution.
  9563. +  * 3. All advertising materials mentioning features or use of this software
  9564. +  *    must display the following acknowledgement:
  9565. +  *    This product includes software developed by the University of
  9566. +  *    California, Berkeley and its contributors.
  9567. +  * 4. Neither the name of the University nor the names of its contributors
  9568. +  *    may be used to endorse or promote products derived from this software
  9569. +  *    without specific prior written permission.
  9570. +  *
  9571. +  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  9572. +  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  9573. +  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  9574. +  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  9575. +  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  9576. +  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  9577. +  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  9578. +  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  9579. +  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  9580. +  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  9581. +  * SUCH DAMAGE.
  9582. +  *
  9583. +  *    @(#)if_lereg.h    7.1 (Berkeley) 5/8/90
  9584. +  */
  9585. + #define    LEID        21
  9586. + #define    LEMTU        1518
  9587. + #define    LEMINSIZE    60    /* should be 64 if mode DTCR is set */
  9588. + /* HP seems to have 16K RAM on board, A2065/Ameristar come with 32K.
  9589. +    First try to get a working driver with the HP values, and later 
  9590. +    try and see whether 32K works too. */
  9591. + #define LE_USE_32K
  9592. + #ifdef LE_USE_16K
  9593. + #define    LERBUF        8
  9594. + #define    LERBUFLOG2    3
  9595. + #define    LETBUF        4
  9596. + #define    LETBUFLOG2    2
  9597. + #else /* 32K */
  9598. + #define LERBUF        16
  9599. + #define LERBUFLOG2    4
  9600. + #define LETBUF        4
  9601. + #define LETBUFLOG2    2
  9602. + #endif
  9603. + #define    LE_RLEN        (LERBUFLOG2 << 13)
  9604. + #define    LE_TLEN        (LETBUFLOG2 << 13)
  9605. + #define vu_char        volatile u_char
  9606. + /*
  9607. +  * LANCE registers.
  9608. +  */
  9609. + #if 0
  9610. + /* doesn't exist on amiga, there's autoconfig registers in this area  */
  9611. + struct lereg0 {
  9612. +     u_char    ler0_pad0;
  9613. +     vu_char    ler0_id;    /* ID */
  9614. +     u_char    ler0_pad1;
  9615. +     vu_char    ler0_status;    /* interrupt enable/status */
  9616. + };
  9617. + #endif
  9618. + struct lereg1 {
  9619. +     u_short    ler1_rdp;    /* data port */
  9620. +     u_short    ler1_rap;    /* register select port */
  9621. + };
  9622. + /*
  9623. +  * Overlayed on 16K dual-port RAM.
  9624. +  * Current size is 13,758 bytes with 8 x 1518 receive buffers and
  9625. +  * 1 x 1518 transmit buffer.
  9626. +  */
  9627. + struct lereg2 {
  9628. +     /* init block */
  9629. +     u_short    ler2_mode;        /* +0x0000 */
  9630. +     u_char    ler2_padr[6];        /* +0x0002 */
  9631. +     u_long    ler2_ladrf0;        /* +0x0008 */
  9632. +     u_long    ler2_ladrf1;        /* +0x000C */
  9633. +     u_short    ler2_rdra;        /* +0x0010 */
  9634. +     u_short    ler2_rlen;        /* +0x0012 */
  9635. +     u_short    ler2_tdra;        /* +0x0014 */
  9636. +     u_short    ler2_tlen;        /* +0x0016 */
  9637. +     /* receive message descriptors */
  9638. +     struct    lermd {            /* +0x0018 */
  9639. +         u_short    rmd0;
  9640. +         u_short    rmd1;
  9641. +         short    rmd2;
  9642. +         u_short    rmd3;
  9643. +     } ler2_rmd[LERBUF];
  9644. +     /* transmit message descriptors */
  9645. +     struct    letmd {            /* +0x0058 */
  9646. +         u_short    tmd0;
  9647. +         u_short    tmd1;
  9648. +         short    tmd2;
  9649. +         u_short    tmd3;
  9650. +     } ler2_tmd[LETBUF];
  9651. +     char    ler2_rbuf[LERBUF][LEMTU]; /* +0x0060 */
  9652. +     char    ler2_tbuf[LETBUF][LEMTU]; /* +0x2FD0 */
  9653. + };
  9654. + #if 0
  9655. + /*
  9656. +  * Control and status bits -- lereg0
  9657. +  */
  9658. + #define    LE_IE        0x80        /* interrupt enable */
  9659. + #define    LE_IR        0x40        /* interrupt requested */
  9660. + #define    LE_LOCK        0x08        /* lock status register */
  9661. + #define    LE_ACK        0x04        /* ack of lock */
  9662. + #define    LE_JAB        0x02        /* loss of tx clock (???) */
  9663. + #define LE_IPL(x)    ((((x) >> 4) & 0x3) + 3)
  9664. + #endif
  9665. + /*
  9666. +  * Control and status bits -- lereg1
  9667. +  */
  9668. + #define    LE_CSR0        0
  9669. + #define    LE_CSR1        1
  9670. + #define    LE_CSR2        2
  9671. + #define    LE_CSR3        3
  9672. + #define    LE_SERR        0x8000
  9673. + #define    LE_BABL        0x4000
  9674. + #define    LE_CERR        0x2000
  9675. + #define    LE_MISS        0x1000
  9676. + #define    LE_MERR        0x0800
  9677. + #define    LE_RINT        0x0400
  9678. + #define    LE_TINT        0x0200
  9679. + #define    LE_IDON        0x0100
  9680. + #define    LE_INTR        0x0080
  9681. + #define    LE_INEA        0x0040
  9682. + #define    LE_RXON        0x0020
  9683. + #define    LE_TXON        0x0010
  9684. + #define    LE_TDMD        0x0008
  9685. + #define    LE_STOP        0x0004
  9686. + #define    LE_STRT        0x0002
  9687. + #define    LE_INIT        0x0001
  9688. + #define    LE_BSWP        0x4
  9689. + #define    LE_MODE        0x0
  9690. + /*
  9691. +  * Control and status bits -- lereg2
  9692. +  */
  9693. + #define    LE_OWN        0x8000
  9694. + #define    LE_ERR        0x4000
  9695. + #define    LE_STP        0x0200
  9696. + #define    LE_ENP        0x0100
  9697. + #define    LE_FRAM        0x2000
  9698. + #define    LE_OFLO        0x1000
  9699. + #define    LE_CRC        0x0800
  9700. + #define    LE_RBUFF    0x0400
  9701. + #define    LE_MORE        0x1000
  9702. + #define    LE_ONE        0x0800
  9703. + #define    LE_DEF        0x0400
  9704. + #define    LE_TBUFF    0x8000
  9705. + #define    LE_UFLO        0x4000
  9706. + #define    LE_LCOL        0x1000
  9707. + #define    LE_LCAR        0x0800
  9708. + #define    LE_RTRY        0x0400
  9709. *** old-NetBSD/src/sys/arch/amiga/dev/ite.c
  9710. --- NetBSD/src/sys/arch/amiga/dev/ite.c
  9711. ***************
  9712. *** 295,306 ****
  9713.   }
  9714.   
  9715.   /*
  9716. !  * ite_cnfinish() is called in ite_init() when the device is
  9717.    * being probed in the normal fasion, thus we can finish setting
  9718.    * up this ite now that the system is more functional.
  9719.    */
  9720.   void
  9721. ! ite_cnfinish(ip)
  9722.       struct ite_softc *ip;
  9723.   {
  9724.       static int done;
  9725. --- 295,306 ----
  9726.   }
  9727.   
  9728.   /*
  9729. !  * itecnfinish() is called in iteinit() when the device is
  9730.    * being probed in the normal fasion, thus we can finish setting
  9731.    * up this ite now that the system is more functional.
  9732.    */
  9733.   void
  9734. ! itecnfinish(ip)
  9735.       struct ite_softc *ip;
  9736.   {
  9737.       static int done;
  9738. *** old-NetBSD/src/sys/arch/amiga/dev/itevar.h
  9739. --- NetBSD/src/sys/arch/amiga/dev/itevar.h
  9740. ***************
  9741. *** 193,199 ****
  9742.   void    itecninit __P((struct consdev *));
  9743.   int    itecngetc __P((dev_t));
  9744.   void    itecnputc __P((dev_t, int));
  9745. ! void    ite_cnfinish __P((struct ite_softc *));
  9746.   
  9747.   /* standard ite device entry points. */
  9748.   void    iteinit __P((dev_t));
  9749. --- 193,200 ----
  9750.   void    itecninit __P((struct consdev *));
  9751.   int    itecngetc __P((dev_t));
  9752.   void    itecnputc __P((dev_t, int));
  9753. ! void    itecnfinish __P((struct ite_softc *));
  9754. ! void    itecnpollc __P((dev_t dev,int on));
  9755.   
  9756.   /* standard ite device entry points. */
  9757.   void    iteinit __P((dev_t));
  9758. *** old-NetBSD/src/sys/arch/amiga/dev/kbd.c
  9759. --- NetBSD/src/sys/arch/amiga/dev/kbd.c
  9760. ***************
  9761. *** 54,59 ****
  9762. --- 54,60 ----
  9763.   #include <amiga/dev/event_var.h>
  9764.   #include <amiga/dev/vuid_event.h>
  9765.   #include "kbd.h"
  9766. + #include "grfcc.h"
  9767.   
  9768.   struct kbd_softc {
  9769.       int k_event_mode;    /* if true, collect events, else pass to ite */
  9770. *** /dev/null
  9771. --- NetBSD/src/sys/arch/amiga/dev/kf_custom.c
  9772. ***************
  9773. *** 0 ****
  9774. --- 1,247 ----
  9775. + /*
  9776. + Information on selected font:
  9777. + Name=topaz.font
  9778. + Height=8 tf_Style=0 tf_Flags=41 Width=8 Baseline=6
  9779. + */
  9780. + /* Generated automatically by fontdumper.c. *DONT* distribute
  9781. +    this file, it may contain information Copyright by Commodore!
  9782. +    Font: topaz.font/8
  9783. +  */
  9784. + unsigned char kernel_font_width  = 8;
  9785. + unsigned char kernel_font_height = 8;
  9786. + unsigned char kernel_font_baseline = 6;
  9787. + short         kernel_font_boldsmear = 1;
  9788. + unsigned char kernel_font_lo = 32;
  9789. + unsigned char kernel_font_hi = 255;
  9790. + unsigned char kernel_cursor[] = {
  9791. + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
  9792. + unsigned char kernel_font[] = {
  9793. + /*   */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  9794. + /* ! */ 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x00,
  9795. + /* " */ 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  9796. + /* # */ 0x6c, 0x6c, 0xfe, 0x6c, 0xfe, 0x6c, 0x6c, 0x00,
  9797. + /* $ */ 0x18, 0x3e, 0x60, 0x3c, 0x06, 0x7c, 0x18, 0x00,
  9798. + /* % */ 0x00, 0x66, 0xac, 0xd8, 0x36, 0x6a, 0xcc, 0x00,
  9799. + /* & */ 0x38, 0x6c, 0x68, 0x76, 0xdc, 0xce, 0x7b, 0x00,
  9800. + /* ' */ 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
  9801. + /* ( */ 0x0c, 0x18, 0x30, 0x30, 0x30, 0x18, 0x0c, 0x00,
  9802. + /* ) */ 0x30, 0x18, 0x0c, 0x0c, 0x0c, 0x18, 0x30, 0x00,
  9803. + /* * */ 0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00,
  9804. + /* + */ 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00,
  9805. + /* , */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30,
  9806. + /* - */ 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00,
  9807. + /* . */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00,
  9808. + /* / */ 0x03, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x00,
  9809. + /* 0 */ 0x3c, 0x66, 0x6e, 0x7e, 0x76, 0x66, 0x3c, 0x00,
  9810. + /* 1 */ 0x18, 0x38, 0x78, 0x18, 0x18, 0x18, 0x18, 0x00,
  9811. + /* 2 */ 0x3c, 0x66, 0x06, 0x0c, 0x18, 0x30, 0x7e, 0x00,
  9812. + /* 3 */ 0x3c, 0x66, 0x06, 0x1c, 0x06, 0x66, 0x3c, 0x00,
  9813. + /* 4 */ 0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x0c, 0x00,
  9814. + /* 5 */ 0x7e, 0x60, 0x7c, 0x06, 0x06, 0x66, 0x3c, 0x00,
  9815. + /* 6 */ 0x1c, 0x30, 0x60, 0x7c, 0x66, 0x66, 0x3c, 0x00,
  9816. + /* 7 */ 0x7e, 0x06, 0x06, 0x0c, 0x18, 0x18, 0x18, 0x00,
  9817. + /* 8 */ 0x3c, 0x66, 0x66, 0x3c, 0x66, 0x66, 0x3c, 0x00,
  9818. + /* 9 */ 0x3c, 0x66, 0x66, 0x3e, 0x06, 0x0c, 0x38, 0x00,
  9819. + /* : */ 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00,
  9820. + /* ; */ 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x30,
  9821. + /* < */ 0x00, 0x06, 0x18, 0x60, 0x18, 0x06, 0x00, 0x00,
  9822. + /* = */ 0x00, 0x00, 0x7e, 0x00, 0x7e, 0x00, 0x00, 0x00,
  9823. + /* > */ 0x00, 0x60, 0x18, 0x06, 0x18, 0x60, 0x00, 0x00,
  9824. + /* ? */ 0x3c, 0x66, 0x06, 0x0c, 0x18, 0x00, 0x18, 0x00,
  9825. + /* @ */ 0x7c, 0xc6, 0xde, 0xd6, 0xde, 0xc0, 0x78, 0x00,
  9826. + /* A */ 0x3c, 0x66, 0x66, 0x7e, 0x66, 0x66, 0x66, 0x00,
  9827. + /* B */ 0x7c, 0x66, 0x66, 0x7c, 0x66, 0x66, 0x7c, 0x00,
  9828. + /* C */ 0x1e, 0x30, 0x60, 0x60, 0x60, 0x30, 0x1e, 0x00,
  9829. + /* D */ 0x78, 0x6c, 0x66, 0x66, 0x66, 0x6c, 0x78, 0x00,
  9830. + /* E */ 0x7e, 0x60, 0x60, 0x78, 0x60, 0x60, 0x7e, 0x00,
  9831. + /* F */ 0x7e, 0x60, 0x60, 0x78, 0x60, 0x60, 0x60, 0x00,
  9832. + /* G */ 0x3c, 0x66, 0x60, 0x6e, 0x66, 0x66, 0x3e, 0x00,
  9833. + /* H */ 0x66, 0x66, 0x66, 0x7e, 0x66, 0x66, 0x66, 0x00,
  9834. + /* I */ 0x3c, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00,
  9835. + /* J */ 0x06, 0x06, 0x06, 0x06, 0x06, 0x66, 0x3c, 0x00,
  9836. + /* K */ 0xc6, 0xcc, 0xd8, 0xf0, 0xd8, 0xcc, 0xc6, 0x00,
  9837. + /* L */ 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7e, 0x00,
  9838. + /* M */ 0xc6, 0xee, 0xfe, 0xd6, 0xc6, 0xc6, 0xc6, 0x00,
  9839. + /* N */ 0xc6, 0xe6, 0xf6, 0xde, 0xce, 0xc6, 0xc6, 0x00,
  9840. + /* O */ 0x3c, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x00,
  9841. + /* P */ 0x7c, 0x66, 0x66, 0x7c, 0x60, 0x60, 0x60, 0x00,
  9842. + /* Q */ 0x78, 0xcc, 0xcc, 0xcc, 0xcc, 0xdc, 0x7e, 0x00,
  9843. + /* R */ 0x7c, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0x66, 0x00,
  9844. + /* S */ 0x3c, 0x66, 0x70, 0x3c, 0x0e, 0x66, 0x3c, 0x00,
  9845. + /* T */ 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00,
  9846. + /* U */ 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x00,
  9847. + /* V */ 0x66, 0x66, 0x66, 0x66, 0x3c, 0x3c, 0x18, 0x00,
  9848. + /* W */ 0xc6, 0xc6, 0xc6, 0xd6, 0xfe, 0xee, 0xc6, 0x00,
  9849. + /* X */ 0xc3, 0x66, 0x3c, 0x18, 0x3c, 0x66, 0xc3, 0x00,
  9850. + /* Y */ 0xc3, 0x66, 0x3c, 0x18, 0x18, 0x18, 0x18, 0x00,
  9851. + /* Z */ 0xfe, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0xfe, 0x00,
  9852. + /* [ */ 0x3c, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3c, 0x00,
  9853. + /* \ */ 0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x03, 0x00,
  9854. + /* ] */ 0x3c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x3c, 0x00,
  9855. + /* ^ */ 0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00,
  9856. + /* _ */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe,
  9857. + /* ` */ 0x18, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
  9858. + /* a */ 0x00, 0x00, 0x3c, 0x06, 0x3e, 0x66, 0x3e, 0x00,
  9859. + /* b */ 0x60, 0x60, 0x7c, 0x66, 0x66, 0x66, 0x7c, 0x00,
  9860. + /* c */ 0x00, 0x00, 0x3c, 0x60, 0x60, 0x60, 0x3c, 0x00,
  9861. + /* d */ 0x06, 0x06, 0x3e, 0x66, 0x66, 0x66, 0x3e, 0x00,
  9862. + /* e */ 0x00, 0x00, 0x3c, 0x66, 0x7e, 0x60, 0x3c, 0x00,
  9863. + /* f */ 0x1c, 0x30, 0x7c, 0x30, 0x30, 0x30, 0x30, 0x00,
  9864. + /* g */ 0x00, 0x00, 0x3e, 0x66, 0x66, 0x3e, 0x06, 0x3c,
  9865. + /* h */ 0x60, 0x60, 0x7c, 0x66, 0x66, 0x66, 0x66, 0x00,
  9866. + /* i */ 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x0c, 0x00,
  9867. + /* j */ 0x0c, 0x00, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x78,
  9868. + /* k */ 0x60, 0x60, 0x66, 0x6c, 0x78, 0x6c, 0x66, 0x00,
  9869. + /* l */ 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x0c, 0x00,
  9870. + /* m */ 0x00, 0x00, 0xec, 0xfe, 0xd6, 0xc6, 0xc6, 0x00,
  9871. + /* n */ 0x00, 0x00, 0x7c, 0x66, 0x66, 0x66, 0x66, 0x00,
  9872. + /* o */ 0x00, 0x00, 0x3c, 0x66, 0x66, 0x66, 0x3c, 0x00,
  9873. + /* p */ 0x00, 0x00, 0x7c, 0x66, 0x66, 0x7c, 0x60, 0x60,
  9874. + /* q */ 0x00, 0x00, 0x3e, 0x66, 0x66, 0x3e, 0x06, 0x06,
  9875. + /* r */ 0x00, 0x00, 0x7c, 0x66, 0x60, 0x60, 0x60, 0x00,
  9876. + /* s */ 0x00, 0x00, 0x3c, 0x60, 0x3c, 0x06, 0x7c, 0x00,
  9877. + /* t */ 0x30, 0x30, 0x7c, 0x30, 0x30, 0x30, 0x1c, 0x00,
  9878. + /* u */ 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3e, 0x00,
  9879. + /* v */ 0x00, 0x00, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x00,
  9880. + /* w */ 0x00, 0x00, 0xc6, 0xc6, 0xd6, 0xfe, 0x6c, 0x00,
  9881. + /* x */ 0x00, 0x00, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0x00,
  9882. + /* y */ 0x00, 0x00, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x30,
  9883. + /* z */ 0x00, 0x00, 0x7e, 0x0c, 0x18, 0x30, 0x7e, 0x00,
  9884. + /* { */ 0x0e, 0x18, 0x18, 0x70, 0x18, 0x18, 0x0e, 0x00,
  9885. + /* | */ 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00,
  9886. + /* } */ 0x70, 0x18, 0x18, 0x0e, 0x18, 0x18, 0x70, 0x00,
  9887. + /* ~ */ 0x72, 0x9c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  9888. + /*  */ 0x0f, 0x3c, 0xf0, 0xc3, 0x0f, 0x3c, 0xf0, 0x00,
  9889. + /* € */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9890. + /*  */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9891. + /* ‚ */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9892. + /* ƒ */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9893. + /* „ */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9894. + /* … */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9895. + /* † */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9896. + /* ‡ */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9897. + /* ˆ */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9898. + /* ‰ */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9899. + /* Š */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9900. + /* ‹ */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9901. + /* Œ */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9902. + /*  */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9903. + /* Ž */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9904. + /*  */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9905. + /*  */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9906. + /* ‘ */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9907. + /* ’ */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9908. + /* “ */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9909. + /* ” */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9910. + /* • */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9911. + /* – */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9912. + /* — */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9913. + /* ˜ */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9914. + /* ™ */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9915. + /* š */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9916. + /* › */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9917. + /* œ */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9918. + /*  */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9919. + /* ž */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9920. + /* Ÿ */ 0x00, 0x7e, 0x66, 0x66, 0x66, 0x66, 0x7e, 0x00,
  9921. + /*   */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  9922. + /* ¡ */ 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00,
  9923. + /* ¢ */ 0x00, 0x0c, 0x3e, 0x6c, 0x3e, 0x0c, 0x00, 0x00,
  9924. + /* £ */ 0x1c, 0x36, 0x30, 0x78, 0x30, 0x30, 0x7e, 0x00,
  9925. + /* ¤ */ 0x42, 0x3c, 0x66, 0x3c, 0x42, 0x00, 0x00, 0x00,
  9926. + /* ¥ */ 0xc3, 0x66, 0x3c, 0x18, 0x3c, 0x18, 0x18, 0x00,
  9927. + /* ¦ */ 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00,
  9928. + /* § */ 0x3c, 0x60, 0x3c, 0x66, 0x3c, 0x06, 0x3c, 0x00,
  9929. + /* ¨ */ 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  9930. + /* © */ 0x7e, 0x81, 0x9d, 0xb1, 0x9d, 0x81, 0x7e, 0x00,
  9931. + /* ª */ 0x1c, 0x24, 0x44, 0x3c, 0x00, 0x7e, 0x00, 0x00,
  9932. + /* « */ 0x00, 0x33, 0x66, 0xcc, 0x66, 0x33, 0x00, 0x00,
  9933. + /* ¬ */ 0x3e, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  9934. + /* ­ */ 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00,
  9935. + /* ® */ 0x7e, 0x81, 0xb9, 0xa5, 0xb9, 0xa5, 0x81, 0x7e,
  9936. + /* ¯ */ 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  9937. + /* ° */ 0x3c, 0x66, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00,
  9938. + /* ± */ 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x7e, 0x00,
  9939. + /* ² */ 0x78, 0x0c, 0x18, 0x30, 0x7c, 0x00, 0x00, 0x00,
  9940. + /* ³ */ 0x78, 0x0c, 0x18, 0x0c, 0x78, 0x00, 0x00, 0x00,
  9941. + /* ´ */ 0x18, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00,
  9942. + /* µ */ 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x7f, 0x60,
  9943. + /* ¶ */ 0x3e, 0x7a, 0x7a, 0x3a, 0x0a, 0x0a, 0x0a, 0x00,
  9944. + /* · */ 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00,
  9945. + /* ¸ */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x30,
  9946. + /* ¹ */ 0x30, 0x70, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00,
  9947. + /* º */ 0x38, 0x44, 0x44, 0x38, 0x00, 0x7c, 0x00, 0x00,
  9948. + /* » */ 0x00, 0xcc, 0x66, 0x33, 0x66, 0xcc, 0x00, 0x00,
  9949. + /* ¼ */ 0x40, 0xc6, 0x4c, 0x58, 0x32, 0x66, 0xcf, 0x02,
  9950. + /* ½ */ 0x40, 0xc6, 0x4c, 0x58, 0x3e, 0x62, 0xc4, 0x0e,
  9951. + /* ¾ */ 0xc0, 0x23, 0x66, 0x2c, 0xd9, 0x33, 0x67, 0x01,
  9952. + /* ¿ */ 0x18, 0x00, 0x18, 0x30, 0x60, 0x66, 0x3c, 0x00,
  9953. + /* À */ 0x30, 0x18, 0x3c, 0x66, 0x7e, 0x66, 0x66, 0x00,
  9954. + /* Á */ 0x0c, 0x18, 0x3c, 0x66, 0x7e, 0x66, 0x66, 0x00,
  9955. + /* Â */ 0x18, 0x66, 0x3c, 0x66, 0x7e, 0x66, 0x66, 0x00,
  9956. + /* Ã */ 0x71, 0x8e, 0x3c, 0x66, 0x7e, 0x66, 0x66, 0x00,
  9957. + /* Ä */ 0x66, 0x00, 0x3c, 0x66, 0x7e, 0x66, 0x66, 0x00,
  9958. + /* Å */ 0x18, 0x24, 0x3c, 0x66, 0x7e, 0x66, 0x66, 0x00,
  9959. + /* Æ */ 0x1f, 0x3c, 0x3c, 0x6f, 0x7c, 0xcc, 0xcf, 0x00,
  9960. + /* Ç */ 0x1e, 0x30, 0x60, 0x60, 0x30, 0x1e, 0x0c, 0x18,
  9961. + /* È */ 0x30, 0x18, 0x7e, 0x60, 0x78, 0x60, 0x7e, 0x00,
  9962. + /* É */ 0x0c, 0x18, 0x7e, 0x60, 0x78, 0x60, 0x7e, 0x00,
  9963. + /* Ê */ 0x18, 0x66, 0x7e, 0x60, 0x78, 0x60, 0x7e, 0x00,
  9964. + /* Ë */ 0x66, 0x00, 0x7e, 0x60, 0x78, 0x60, 0x7e, 0x00,
  9965. + /* Ì */ 0x30, 0x18, 0x3c, 0x18, 0x18, 0x18, 0x3c, 0x00,
  9966. + /* Í */ 0x0c, 0x18, 0x3c, 0x18, 0x18, 0x18, 0x3c, 0x00,
  9967. + /* Î */ 0x18, 0x66, 0x3c, 0x18, 0x18, 0x18, 0x3c, 0x00,
  9968. + /* Ï */ 0x66, 0x00, 0x3c, 0x18, 0x18, 0x18, 0x3c, 0x00,
  9969. + /* Ð */ 0x78, 0x6c, 0x66, 0xf6, 0x66, 0x6c, 0x78, 0x00,
  9970. + /* Ñ */ 0x71, 0xce, 0xe6, 0xf6, 0xde, 0xce, 0xc6, 0x00,
  9971. + /* Ò */ 0x30, 0x18, 0x3c, 0x66, 0x66, 0x66, 0x3c, 0x00,
  9972. + /* Ó */ 0x0c, 0x18, 0x3c, 0x66, 0x66, 0x66, 0x3c, 0x00,
  9973. + /* Ô */ 0x18, 0x66, 0x3c, 0x66, 0x66, 0x66, 0x3c, 0x00,
  9974. + /* Õ */ 0x71, 0x8e, 0x3c, 0x66, 0x66, 0x66, 0x3c, 0x00,
  9975. + /* Ö */ 0xc3, 0x3c, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x00,
  9976. + /* × */ 0x00, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0x00, 0x00,
  9977. + /* Ø */ 0x3f, 0x66, 0x6e, 0x7e, 0x76, 0x66, 0xfc, 0x00,
  9978. + /* Ù */ 0x30, 0x18, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x00,
  9979. + /* Ú */ 0x0c, 0x18, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x00,
  9980. + /* Û */ 0x18, 0x24, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x00,
  9981. + /* Ü */ 0x66, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x00,
  9982. + /* Ý */ 0x06, 0x08, 0xc3, 0x66, 0x3c, 0x18, 0x18, 0x00,
  9983. + /* Þ */ 0xc0, 0xc0, 0xfc, 0xc6, 0xfc, 0xc0, 0xc0, 0x00,
  9984. + /* ß */ 0x3c, 0x66, 0x66, 0x6c, 0x66, 0x66, 0x6c, 0x60,
  9985. + /* à */ 0x30, 0x18, 0x3c, 0x06, 0x3e, 0x66, 0x3e, 0x00,
  9986. + /* á */ 0x0c, 0x18, 0x3c, 0x06, 0x3e, 0x66, 0x3e, 0x00,
  9987. + /* â */ 0x18, 0x66, 0x3c, 0x06, 0x3e, 0x66, 0x3e, 0x00,
  9988. + /* ã */ 0x71, 0x8e, 0x3c, 0x06, 0x3e, 0x66, 0x3e, 0x00,
  9989. + /* ä */ 0x66, 0x00, 0x3c, 0x06, 0x3e, 0x66, 0x3e, 0x00,
  9990. + /* å */ 0x18, 0x24, 0x3c, 0x06, 0x3e, 0x66, 0x3e, 0x00,
  9991. + /* æ */ 0x00, 0x00, 0x7e, 0x1b, 0x7f, 0xd8, 0x77, 0x00,
  9992. + /* ç */ 0x00, 0x00, 0x3c, 0x60, 0x60, 0x60, 0x3c, 0x18,
  9993. + /* è */ 0x30, 0x18, 0x3c, 0x66, 0x7e, 0x60, 0x3c, 0x00,
  9994. + /* é */ 0x0c, 0x18, 0x3c, 0x66, 0x7e, 0x60, 0x3c, 0x00,
  9995. + /* ê */ 0x18, 0x66, 0x3c, 0x66, 0x7e, 0x60, 0x3c, 0x00,
  9996. + /* ë */ 0x66, 0x00, 0x3c, 0x66, 0x7e, 0x60, 0x3c, 0x00,
  9997. + /* ì */ 0x30, 0x18, 0x00, 0x18, 0x18, 0x18, 0x0c, 0x00,
  9998. + /* í */ 0x0c, 0x18, 0x00, 0x18, 0x18, 0x18, 0x0c, 0x00,
  9999. + /* î */ 0x18, 0x66, 0x00, 0x18, 0x18, 0x18, 0x0c, 0x00,
  10000. + /* ï */ 0x00, 0x66, 0x00, 0x18, 0x18, 0x18, 0x0c, 0x00,
  10001. + /* ð */ 0x60, 0xfc, 0x18, 0x3c, 0x66, 0x66, 0x3c, 0x00,
  10002. + /* ñ */ 0x71, 0x8e, 0x00, 0x7c, 0x66, 0x66, 0x66, 0x00,
  10003. + /* ò */ 0x30, 0x18, 0x00, 0x3c, 0x66, 0x66, 0x3c, 0x00,
  10004. + /* ó */ 0x0c, 0x18, 0x00, 0x3c, 0x66, 0x66, 0x3c, 0x00,
  10005. + /* ô */ 0x18, 0x66, 0x00, 0x3c, 0x66, 0x66, 0x3c, 0x00,
  10006. + /* õ */ 0x71, 0x8e, 0x00, 0x3c, 0x66, 0x66, 0x3c, 0x00,
  10007. + /* ö */ 0x00, 0x66, 0x00, 0x3c, 0x66, 0x66, 0x3c, 0x00,
  10008. + /* ÷ */ 0x00, 0x18, 0x00, 0x7e, 0x00, 0x18, 0x00, 0x00,
  10009. + /* ø */ 0x00, 0x02, 0x7c, 0xce, 0xd6, 0xe6, 0x7c, 0x80,
  10010. + /* ù */ 0x30, 0x18, 0x00, 0x66, 0x66, 0x66, 0x3e, 0x00,
  10011. + /* ú */ 0x0c, 0x18, 0x00, 0x66, 0x66, 0x66, 0x3e, 0x00,
  10012. + /* û */ 0x18, 0x66, 0x00, 0x66, 0x66, 0x66, 0x3e, 0x00,
  10013. + /* ü */ 0x00, 0x66, 0x00, 0x66, 0x66, 0x66, 0x3e, 0x00,
  10014. + /* ý */ 0x0c, 0x18, 0x00, 0x66, 0x66, 0x3c, 0x18, 0x30,
  10015. + /* þ */ 0x60, 0x60, 0x7c, 0x66, 0x66, 0x7c, 0x60, 0x60,
  10016. + /* ÿ */ 0x00, 0x66, 0x00, 0x66, 0x66, 0x3c, 0x18, 0x30,
  10017. + };
  10018. *** old-NetBSD/src/sys/arch/amiga/dev/mfc.c
  10019. --- NetBSD/src/sys/arch/amiga/dev/mfc.c
  10020. ***************
  10021. *** 359,364 ****
  10022. --- 359,365 ----
  10023.       scc->sc_isr.isr_intr = mfcintr;
  10024.       scc->sc_isr.isr_arg = scc;
  10025.       scc->sc_isr.isr_ipl = 6;
  10026. +     scc->sc_isr.isr_mapped_ipl = 3;
  10027.       add_isr(&scc->sc_isr);
  10028.   
  10029.       /* configure ports */
  10030. ***************
  10031. *** 408,414 ****
  10032.       if (dp) {
  10033.           printf (": input fifo %d output fifo %d\n", SERIBUF_SIZE,
  10034.               SEROBUF_SIZE);
  10035. -         alloc_sicallback();
  10036.       }
  10037.   
  10038.       unit = ma->unit;
  10039. --- 409,414 ----
  10040. ***************
  10041. *** 988,997 ****
  10042.               tp->t_state &= ~(TS_BUSY | TS_FLUSH);
  10043.               scc->imask &= ~0x01;
  10044.               regs->du_imr = scc->imask;
  10045. !             add_sicallback (tp->t_line ?
  10046. !                 linesw[tp->t_line].l_start : mfcsstart,
  10047. !                 tp, NULL);
  10048.           }
  10049.           else
  10050.               regs->du_tba = *sc->ptr++;
  10051. --- 988,997 ----
  10052.               tp->t_state &= ~(TS_BUSY | TS_FLUSH);
  10053.               scc->imask &= ~0x01;
  10054.               regs->du_imr = scc->imask;
  10055. !             if (tp->t_line)
  10056. !                 (*linesw[tp->t_line].l_start)(tp);
  10057. !             else
  10058. !                 mfcsstart(tp);
  10059.           }
  10060.           else
  10061.               regs->du_tba = *sc->ptr++;
  10062. ***************
  10063. *** 1003,1011 ****
  10064.               tp->t_state &= ~(TS_BUSY | TS_FLUSH);
  10065.               scc->imask &= ~0x10;
  10066.               regs->du_imr = scc->imask;
  10067. !             add_sicallback (tp->t_line ?
  10068. !                 linesw[tp->t_line].l_start : mfcsstart,
  10069. !                 tp, NULL);
  10070.           }
  10071.           else
  10072.               regs->du_tbb = *sc->ptr++;
  10073. --- 1003,1012 ----
  10074.               tp->t_state &= ~(TS_BUSY | TS_FLUSH);
  10075.               scc->imask &= ~0x10;
  10076.               regs->du_imr = scc->imask;
  10077. !             if (tp->t_line)
  10078. !                 (*linesw[tp->t_line].l_start)(tp);
  10079. !             else
  10080. !                 mfcsstart(tp);
  10081.           }
  10082.           else
  10083.               regs->du_tbb = *sc->ptr++;
  10084. *** old-NetBSD/src/sys/arch/amiga/dev/ms.c
  10085. --- NetBSD/src/sys/arch/amiga/dev/ms.c
  10086. ***************
  10087. *** 179,184 ****
  10088. --- 179,188 ----
  10089.       pra >>= unit == 0 ? 6 : 7;    /* contains left button */
  10090.       mb = (pot & 4) / 4 + (pot & 1) * 2 + (pra & 1) * 4;
  10091.       mb ^= 0x07;
  10092. + #ifdef EMULATE_3_BUTTONS
  10093. +     if (mb == 5)
  10094. +         mb = 2;
  10095. + #endif
  10096.   
  10097.       /*
  10098.        * read current values of counter registers
  10099. *** old-NetBSD/src/sys/arch/amiga/dev/par.c
  10100. --- NetBSD/src/sys/arch/amiga/dev/par.c
  10101. ***************
  10102. *** 54,59 ****
  10103. --- 54,61 ----
  10104.   #include <amiga/amiga/cia.h>
  10105.   #include <amiga/dev/parioctl.h>
  10106.   
  10107. + /* this used to be in systm.h */
  10108. + typedef void (*timeout_t) __P((void *));
  10109.   
  10110.   struct    par_softc {
  10111.       int    sc_flags;
  10112. ***************
  10113. *** 61,66 ****
  10114. --- 63,70 ----
  10115.   #define sc_burst sc_param.burst
  10116.   #define sc_timo  sc_param.timo
  10117.   #define sc_delay sc_param.delay
  10118. +     u_char    *sc_buf;
  10119. +     u_int    sc_buflen;
  10120.   } *par_softcp;
  10121.   
  10122.   #define getparsp(x)    (x > 0 ? NULL : par_softcp)
  10123. ***************
  10124. *** 153,158 ****
  10125. --- 157,166 ----
  10126.       sc->sc_burst = PAR_BURST;
  10127.       sc->sc_timo = parmstohz(PAR_TIMO);
  10128.       sc->sc_delay = parmstohz(PAR_DELAY);
  10129. +     sc->sc_buf = (u_char*) malloc (sc->sc_burst, M_DEVBUF, M_WAITOK);
  10130. +     sc->sc_buflen = sc->sc_burst;
  10131.       /* enable interrupts for CIAA-FLG */
  10132.       ciaa.icr = CIA_ICR_IR_SC | CIA_ICR_FLG;
  10133.       return(0);
  10134. ***************
  10135. *** 170,175 ****
  10136. --- 178,188 ----
  10137.          dev, flags, sc->sc_flags);
  10138.   #endif
  10139.     sc->sc_flags &= ~(PARF_OPEN|PARF_OREAD|PARF_OWRITE);
  10140. +   free(sc->sc_buf, M_DEVBUF);
  10141. +   sc->sc_buf = 0;
  10142. +   sc->sc_buflen = 0;
  10143.     /* don't allow interrupts for CIAA-FLG any longer */
  10144.     ciaa.icr = CIA_ICR_FLG;
  10145.     return(0);
  10146. ***************
  10147. *** 258,269 ****
  10148.          sc->sc_burst, sc->sc_timo, uio->uio_resid);
  10149.   #endif
  10150.     buflen = min(sc->sc_burst, uio->uio_resid);
  10151. !   buf = (char *)malloc(buflen, M_DEVBUF, M_WAITOK);
  10152.     sc->sc_flags |= PARF_UIO;
  10153.     if (sc->sc_timo > 0) 
  10154.       {
  10155.         sc->sc_flags |= PARF_TIMO;
  10156. !       timeout(partimo, (void *)unit, sc->sc_timo);
  10157.       }
  10158.     while (uio->uio_resid > 0) 
  10159.       {
  10160. --- 271,282 ----
  10161.          sc->sc_burst, sc->sc_timo, uio->uio_resid);
  10162.   #endif
  10163.     buflen = min(sc->sc_burst, uio->uio_resid);
  10164. !   buf = sc->sc_buf;
  10165.     sc->sc_flags |= PARF_UIO;
  10166.     if (sc->sc_timo > 0) 
  10167.       {
  10168.         sc->sc_flags |= PARF_TIMO;
  10169. !       timeout((timeout_t) partimo, (void *) unit, sc->sc_timo);
  10170.       }
  10171.     while (uio->uio_resid > 0) 
  10172.       {
  10173. ***************
  10174. *** 276,290 ****
  10175.           break;
  10176.       }
  10177.   again:
  10178. -       s = splbio();
  10179. - #if 0
  10180. -       if ((sc->sc_flags & PARF_UIO) && hpibreq(&sc->sc_dq) == 0)
  10181. -     sleep(sc, PRIBIO+1);
  10182. - #endif
  10183.         /*
  10184. !        * Check if we timed out during sleep or uiomove
  10185.          */
  10186. !       (void) splsoftclock();
  10187.         if ((sc->sc_flags & PARF_UIO) == 0) 
  10188.       {
  10189.   #ifdef DEBUG
  10190. --- 289,298 ----
  10191.           break;
  10192.       }
  10193.   again:
  10194.         /*
  10195. !        * Check if we timed out during uiomove
  10196.          */
  10197. !       s = splsoftclock();
  10198.         if ((sc->sc_flags & PARF_UIO) == 0) 
  10199.       {
  10200.   #ifdef DEBUG
  10201. ***************
  10202. *** 294,300 ****
  10203.   #endif
  10204.         if (sc->sc_flags & PARF_TIMO) 
  10205.           {
  10206. !           untimeout(partimo, (void *)unit);
  10207.             sc->sc_flags &= ~PARF_TIMO;
  10208.           }
  10209.         splx(s);
  10210. --- 302,308 ----
  10211.   #endif
  10212.         if (sc->sc_flags & PARF_TIMO) 
  10213.           {
  10214. !           untimeout((timeout_t) partimo, (void *) unit);
  10215.             sc->sc_flags &= ~PARF_TIMO;
  10216.           }
  10217.         splx(s);
  10218. ***************
  10219. *** 316,324 ****
  10220.       }
  10221.         
  10222.         s = splbio();
  10223. - #if 0
  10224. -       hpibfree(&sc->sc_dq);
  10225. - #endif
  10226.   #ifdef DEBUG
  10227.         if (pardebug & PDB_IO)
  10228.       printf("parrw: %s(%x, %d) -> %d\n",
  10229. --- 324,329 ----
  10230. ***************
  10231. *** 357,367 ****
  10232.         /*
  10233.          * Implement inter-read delay
  10234.          */
  10235. !       if (sc->sc_delay > 0) 
  10236.       {
  10237.         sc->sc_flags |= PARF_DELAY;
  10238. !       timeout(parstart, (void *)unit, sc->sc_delay);
  10239. !       error = tsleep(sc, PCATCH|PZERO-1, "par-cdelay", 0);
  10240.         if (error) 
  10241.           {
  10242.             splx(s);
  10243. --- 362,372 ----
  10244.         /*
  10245.          * Implement inter-read delay
  10246.          */
  10247. !       if (uio->uio_rw == UIO_READ && sc->sc_delay > 0) 
  10248.       {
  10249.         sc->sc_flags |= PARF_DELAY;
  10250. !       timeout((timeout_t) parstart, (void *) unit, sc->sc_delay);
  10251. !       error = tsleep((caddr_t) sc, PCATCH|PZERO-1, "par-cdelay", 0);
  10252.         if (error) 
  10253.           {
  10254.             splx(s);
  10255. ***************
  10256. *** 384,395 ****
  10257.     s = splsoftclock();
  10258.     if (sc->sc_flags & PARF_TIMO) 
  10259.       {
  10260. !       untimeout(partimo, (void *)unit);
  10261.         sc->sc_flags &= ~PARF_TIMO;
  10262.       }
  10263.     if (sc->sc_flags & PARF_DELAY) 
  10264.       {
  10265. !       untimeout(parstart, (void *)unit);
  10266.         sc->sc_flags &= ~PARF_DELAY;
  10267.       }
  10268.     splx(s);
  10269. --- 389,400 ----
  10270.     s = splsoftclock();
  10271.     if (sc->sc_flags & PARF_TIMO) 
  10272.       {
  10273. !       untimeout((timeout_t) partimo, (void *) unit);
  10274.         sc->sc_flags &= ~PARF_TIMO;
  10275.       }
  10276.     if (sc->sc_flags & PARF_DELAY) 
  10277.       {
  10278. !       untimeout((timeout_t) parstart, (void *) unit);
  10279.         sc->sc_flags &= ~PARF_DELAY;
  10280.       }
  10281.     splx(s);
  10282. ***************
  10283. *** 405,411 ****
  10284.              len-cnt);
  10285.   #endif
  10286.       }
  10287. -   free(buf, M_DEVBUF);
  10288.   #ifdef DEBUG
  10289.     if (pardebug & (PDB_FOLLOW|PDB_IO))
  10290.       printf("parrw: return %d, resid %d\n", error, uio->uio_resid);
  10291. --- 410,415 ----
  10292. ***************
  10293. *** 444,449 ****
  10294. --- 448,459 ----
  10295.         pp->burst = upp->burst;
  10296.         pp->timo = parmstohz(upp->timo);
  10297.         pp->delay = parmstohz(upp->delay);
  10298. +       if (pp->burst > sc->sc_buflen) 
  10299. +     {
  10300. +             free (sc->sc_buf, M_DEVBUF);
  10301. +       sc->sc_buf = (u_char *) malloc (sc->sc_burst, M_DEVBUF, M_WAITOK);
  10302. +       sc->sc_buflen = sc->sc_burst;
  10303. +     }
  10304.         break;
  10305.   
  10306.       default:
  10307. ***************
  10308. *** 479,489 ****
  10309.     return(h);
  10310.   }
  10311.   
  10312. ! /* stuff below here if for interrupt driven output of data thru
  10313.      the parallel port. */
  10314.   
  10315.   int partimeout_pending;
  10316.   int parsend_pending;
  10317.   
  10318.   void
  10319.   parintr(arg)
  10320. --- 489,500 ----
  10321.     return(h);
  10322.   }
  10323.   
  10324. ! /* stuff below here is for interrupt driven output of data thru
  10325.      the parallel port. */
  10326.   
  10327.   int partimeout_pending;
  10328.   int parsend_pending;
  10329. + u_char *parbp;
  10330.   
  10331.   void
  10332.   parintr(arg)
  10333. ***************
  10334. *** 498,581 ****
  10335.       if (pardebug & PDB_INTERRUPT)
  10336.           printf("parintr %s\n", mask ? "FLG" : "tout");
  10337.   #endif
  10338. !     /*
  10339. !      * if invoked from timeout handler, mask will be 0,
  10340. !      * if from interrupt, it will contain the cia-icr mask,
  10341. !      * which is != 0
  10342. !      */
  10343. !     if (mask) {
  10344. !         if (partimeout_pending)
  10345. !             untimeout(parintr, 0);
  10346. !         if (parsend_pending)
  10347. !             parsend_pending = 0;
  10348. !     }
  10349. !     /* either way, there won't be a timeout pending any longer */
  10350.       partimeout_pending = 0;
  10351. !   
  10352. !     wakeup(parintr);
  10353. !     splx(s);
  10354.   }
  10355.   
  10356.   int
  10357. ! parsendch (ch)
  10358. !      u_char ch;
  10359.   {
  10360. !   int error = 0;
  10361. !   int s;
  10362. !   /* if either offline, busy or out of paper, wait for that
  10363. !      condition to clear */
  10364. !   s = splclock();
  10365. !   while (!error 
  10366. !      && (parsend_pending 
  10367. !          || ((ciab.pra ^ CIAB_PRA_SEL)
  10368. !          & (CIAB_PRA_SEL|CIAB_PRA_BUSY|CIAB_PRA_POUT))))
  10369. !     {
  10370. !       extern int hz;
  10371.   
  10372. ! #ifdef DEBUG
  10373. !       if (pardebug & PDB_INTERRUPT)
  10374. !     printf ("parsendch, port = $%x\n",
  10375. !         ((ciab.pra ^ CIAB_PRA_SEL)
  10376. !          & (CIAB_PRA_SEL|CIAB_PRA_BUSY|CIAB_PRA_POUT)));
  10377. ! #endif
  10378. !       /* wait a second, and try again */
  10379. !       timeout(parintr, 0, hz);
  10380. !       partimeout_pending = 1;
  10381. !       /* this is essentially a flipflop to have us wait for the
  10382. !      first character being transmitted when trying to transmit
  10383. !      the second, etc. */
  10384. !       parsend_pending = 0;
  10385. !       /* it's quite important that a parallel putc can be
  10386. !      interrupted, given the possibility to lock a printer
  10387. !      in an offline condition.. */
  10388. !       if (error = tsleep(parintr, PCATCH|PZERO-1, "parsendch", 0))
  10389. !     {
  10390. ! #ifdef DEBUG
  10391. !       if (pardebug & PDB_INTERRUPT)
  10392. !         printf ("parsendch interrupted, error = %d\n", error);
  10393. ! #endif
  10394. !       if (partimeout_pending)
  10395. !         untimeout(parintr, 0);
  10396. !       partimeout_pending = 0;
  10397. !     }
  10398. !     }
  10399. !   if (! error)
  10400. !     {
  10401. ! #ifdef DEBUG
  10402. !       if (pardebug & PDB_INTERRUPT)
  10403. !     printf ("#%d", ch);
  10404. ! #endif
  10405. !       ciaa.prb = ch;
  10406. !       parsend_pending = 1;
  10407. !     }
  10408. !   splx (s);
  10409.   
  10410. -   return error;
  10411.   }
  10412.   
  10413.   
  10414. --- 509,545 ----
  10415.       if (pardebug & PDB_INTERRUPT)
  10416.           printf("parintr %s\n", mask ? "FLG" : "tout");
  10417.   #endif
  10418. !     if (partimeout_pending)
  10419. !         untimeout ((timeout_t) parintr, 0);
  10420.       partimeout_pending = 0;
  10421. !     splx (s);
  10422. !     parsendch ();
  10423.   }
  10424.   
  10425.   int
  10426. ! parsendch ()
  10427.   {
  10428. !     int s;
  10429.   
  10430. !     s = splclock();
  10431. !     /* if port is offline, wait a second, and fake a new interrupt, which
  10432. !      * will take us here again. */
  10433. !     if (((ciab.pra ^ CIAB_PRA_SEL)
  10434. !          & (CIAB_PRA_SEL|CIAB_PRA_BUSY|CIAB_PRA_POUT))) {
  10435. !         extern int hz;
  10436. !         timeout ((timeout_t) parintr, 0, hz);
  10437. !         partimeout_pending = 1;
  10438. !     } else if (parsend_pending > 0) {
  10439. !         /* transmit next character */
  10440. !         ciaa.prb = *parbp++;
  10441. !         parsend_pending--;
  10442. !         } else {
  10443. !               /* no more characters to transmit, wake up parsend() */
  10444. !         wakeup ((caddr_t) parintr);
  10445. !         }
  10446. !     splx (s);
  10447.   
  10448.   }
  10449.   
  10450.   
  10451. ***************
  10452. *** 584,604 ****
  10453.        u_char *buf;
  10454.        int len;
  10455.   {
  10456. !   int err, orig_len = len;
  10457.   
  10458. !   /* make sure I/O lines are setup right for output */
  10459.   
  10460. -   /* control lines set to input */
  10461. -   ciab.ddra &= ~(CIAB_PRA_SEL|CIAB_PRA_POUT|CIAB_PRA_BUSY);
  10462. -   /* data lines to output */
  10463. -   ciaa.ddrb = 0xff;
  10464. -   
  10465. -   for (; len; len--, buf++)
  10466. -     if (err = parsendch (*buf))
  10467. -       return err < 0 ? -EINTR : -err;
  10468. -   /* either all or nothing.. */
  10469. -   return orig_len;
  10470.   }
  10471.   
  10472.   
  10473. --- 548,584 ----
  10474.        u_char *buf;
  10475.        int len;
  10476.   {
  10477. !     int err, s;
  10478.   
  10479. !     /* guess that can't happen, right? */
  10480. !     if (len <= 0)
  10481. !         return -EINVAL;
  10482. !     /* make sure I/O lines are setup right for output */
  10483. !     /* control lines set to input */
  10484. !     ciab.ddra &= ~(CIAB_PRA_SEL|CIAB_PRA_POUT|CIAB_PRA_BUSY);
  10485. !     /* data lines to output */
  10486. !     ciaa.ddrb = 0xff;
  10487. !     s = spltty();
  10488. !     /* pass buffer information to interrupt handler */
  10489. !     parbp = buf;
  10490. !     parsend_pending = len;
  10491. !     /* send first character */
  10492. !     parsendch();
  10493. !     err = tsleep ((caddr_t) parintr, PCATCH|PZERO-1, "parsend", 0);
  10494. !     len -= parsend_pending;
  10495. !     parsend_pending = 0;
  10496. !     if (partimeout_pending)
  10497. !         untimeout ((timeout_t) parintr, 0);
  10498. !     splx (s);
  10499. !     if (err)
  10500. !         return err < 0 ? -EINTR : -err;
  10501. !     return len;
  10502.   
  10503.   }
  10504.   
  10505.   
  10506. ***************
  10507. *** 608,616 ****
  10508.        u_char *buf;
  10509.        int len;
  10510.   {
  10511. !   /* oh deary me, something's gotta be left to be implemented
  10512. !      later... */
  10513. !   return 0;
  10514.   }
  10515.   
  10516.   
  10517. --- 588,598 ----
  10518.        u_char *buf;
  10519.        int len;
  10520.   {
  10521. !     /* oh deary me, something's gotta be left to be implemented
  10522. !      * later... */
  10523. !     return 0;
  10524.   }
  10525.   
  10526.   
  10527. *** old-NetBSD/src/sys/arch/amiga/dev/sbic.c
  10528. --- NetBSD/src/sys/arch/amiga/dev/sbic.c
  10529. ***************
  10530. *** 43,48 ****
  10531. --- 43,57 ----
  10532.    * AMIGA AMD 33C93 scsi adaptor driver
  10533.    */
  10534.   
  10535. + /*
  10536. +  * Count the number of controllers using this driver, we need to build
  10537. +  * a sync enable array large enough for all of them.
  10538. +  */
  10539. + #include "ahsc.h"
  10540. + #include "atzsc.h"
  10541. + #include "gtsc.h"
  10542. + #define NSBIC (NAHSC + NATZSC + NGTSC)
  10543.   #include <sys/param.h>
  10544.   #include <sys/systm.h>
  10545.   #include <sys/device.h>
  10546. ***************
  10547. *** 121,131 ****
  10548.   int sbic_data_wait = SBIC_DATA_WAIT;
  10549.   int sbic_init_wait = SBIC_INIT_WAIT;
  10550.   
  10551.   /*
  10552. !  * was broken before.. now if you want this you get it for all drives
  10553. !  * on sbic controllers.
  10554.    */
  10555. ! int sbic_inhibit_sync = 0;
  10556.   int sbic_enable_reselect = 1;
  10557.   int sbic_clock_override = 0;
  10558.   int sbic_no_dma = 0;
  10559. --- 130,141 ----
  10560.   int sbic_data_wait = SBIC_DATA_WAIT;
  10561.   int sbic_init_wait = SBIC_INIT_WAIT;
  10562.   
  10563. + int sbic_cnt = 0;
  10564.   /*
  10565. !  * Another try on individual sync setting.  Trust uninitialized data
  10566. !  * is zero on startup.
  10567.    */
  10568. ! char sbic_inhibit_sync[NSBIC * 8] = { 0 };
  10569.   int sbic_enable_reselect = 1;
  10570.   int sbic_clock_override = 0;
  10571.   int sbic_no_dma = 0;
  10572. ***************
  10573. *** 137,143 ****
  10574.   int    sbicdma_bounces = 0;    /* number operations using bounce buffer */
  10575.   int    sbicdma_hits = 0;    /* number of DMA chains that were contiguous */
  10576.   int    sbicdma_misses = 0;    /* number of DMA chains that were not contiguous */
  10577. ! int     sbicdma_saves = 0;
  10578.   #define QPRINTF(a) if (sbic_debug > 1) printf a
  10579.   int    sbic_debug = 0;
  10580.   int    sync_debug = 0;
  10581. --- 147,153 ----
  10582.   int    sbicdma_bounces = 0;    /* number operations using bounce buffer */
  10583.   int    sbicdma_hits = 0;    /* number of DMA chains that were contiguous */
  10584.   int    sbicdma_misses = 0;    /* number of DMA chains that were not contiguous */
  10585. ! int    sbicdma_saves = 0;
  10586.   #define QPRINTF(a) if (sbic_debug > 1) printf a
  10587.   int    sbic_debug = 0;
  10588.   int    sync_debug = 0;
  10589. ***************
  10590. *** 1027,1033 ****
  10591.            * handle drives that don't want to be asked
  10592.            * whether to go sync at all.
  10593.            */
  10594. !         if (sbic_inhibit_sync && dev->sc_sync[id].state == SYNC_START) {
  10595.   #ifdef DEBUG
  10596.               if (sync_debug)
  10597.                   printf("Forcing target %d asynchronous.\n", id);
  10598. --- 1037,1044 ----
  10599.            * handle drives that don't want to be asked
  10600.            * whether to go sync at all.
  10601.            */
  10602. !         if (sbic_inhibit_sync[id + dev->sc_no]
  10603. !             && dev->sc_sync[id].state == SYNC_START) {
  10604.   #ifdef DEBUG
  10605.               if (sync_debug)
  10606.                   printf("Forcing target %d asynchronous.\n", id);
  10607. *** old-NetBSD/src/sys/arch/amiga/dev/sbicvar.h
  10608. --- NetBSD/src/sys/arch/amiga/dev/sbicvar.h
  10609. ***************
  10610. *** 142,147 ****
  10611. --- 142,148 ----
  10612.       void (*sc_dmafree)    __P((struct sbic_softc *));
  10613.       void (*sc_dmastop)    __P((struct sbic_softc *));
  10614.       u_short    gtsc_bankmask;        /* GVP specific bank selected */
  10615. +     int sc_no;
  10616.   };
  10617.   
  10618.   /* sc_flags */
  10619. ***************
  10620. *** 162,168 ****
  10621.   #define    DDB_FOLLOW    0x04
  10622.   #define DDB_IO        0x08
  10623.   #endif
  10624. ! extern int sbic_inhibit_sync;
  10625.   extern int sbic_no_dma;
  10626.   extern int sbic_clock_override;
  10627.   
  10628. --- 163,170 ----
  10629.   #define    DDB_FOLLOW    0x04
  10630.   #define DDB_IO        0x08
  10631.   #endif
  10632. ! extern int sbic_cnt;
  10633. ! extern char sbic_inhibit_sync[];
  10634.   extern int sbic_no_dma;
  10635.   extern int sbic_clock_override;
  10636.   
  10637. *** old-NetBSD/src/sys/arch/amiga/dev/ser.c
  10638. --- NetBSD/src/sys/arch/amiga/dev/ser.c
  10639. ***************
  10640. *** 35,41 ****
  10641.    *    @(#)ser.c    7.12 (Berkeley) 6/27/91
  10642.    */
  10643.   /*
  10644. !  * XXX This file needs major cleanup it will never ervice more than one
  10645.    * XXX unit.
  10646.    */
  10647.   
  10648. --- 35,41 ----
  10649.    *    @(#)ser.c    7.12 (Berkeley) 6/27/91
  10650.    */
  10651.   /*
  10652. !  * XXX This file needs major cleanup it will never service more than one
  10653.    * XXX unit.
  10654.    */
  10655.   
  10656. ***************
  10657. *** 75,81 ****
  10658.   #define SEROBUF_SIZE 32
  10659.   #endif
  10660.   #ifndef SERIBUF_SIZE
  10661. ! #define SERIBUF_SIZE 512
  10662.   #endif
  10663.   
  10664.   #define splser() spl5()
  10665. --- 75,81 ----
  10666.   #define SEROBUF_SIZE 32
  10667.   #endif
  10668.   #ifndef SERIBUF_SIZE
  10669. ! #define SERIBUF_SIZE 16738
  10670.   #endif
  10671.   
  10672.   #define splser() spl5()
  10673. ***************
  10674. *** 310,321 ****
  10675.           }
  10676.       }
  10677.   done:
  10678. -     /* This is a way to handle lost XON characters */
  10679. -     if ((flag & O_TRUNC) && (tp->t_state & TS_TTSTOP)) {
  10680. -         tp->t_state &= ~TS_TTSTOP;
  10681. -             ttstart (tp);
  10682. -     }
  10683.       splx(s);
  10684.       /*
  10685.        * Reset the tty pointer, as there could have been a dialout
  10686. --- 310,315 ----
  10687. ***************
  10688. *** 725,731 ****
  10689.       return(0);
  10690.   }
  10691.   
  10692. ! int serhwiflow(tp, flag)
  10693.           struct tty *tp;
  10694.           int flag;
  10695.   {
  10696. --- 719,726 ----
  10697.       return(0);
  10698.   }
  10699.   
  10700. ! int
  10701. ! serhwiflow(tp, flag)
  10702.           struct tty *tp;
  10703.           int flag;
  10704.   {
  10705. ***************
  10706. *** 1049,1055 ****
  10707.       short stat;
  10708.       int s;
  10709.   
  10710. !     s = splhigh();
  10711.   
  10712.       if (serconsinit == 0) {
  10713.           (void)serinit(SERUNIT(dev), serdefaultrate);
  10714. --- 1044,1050 ----
  10715.       short stat;
  10716.       int s;
  10717.   
  10718. !     s = splser();
  10719.   
  10720.       if (serconsinit == 0) {
  10721.           (void)serinit(SERUNIT(dev), serdefaultrate);
  10722. *** old-NetBSD/src/sys/arch/amiga/dev/zbus.c
  10723. --- NetBSD/src/sys/arch/amiga/dev/zbus.c
  10724. ***************
  10725. *** 110,115 ****
  10726. --- 110,116 ----
  10727.       { "grfcl",    2193,    1},    /* Spectrum regs */
  10728.       { "grfcl",    2195,    5},    /* Piccolo mem */
  10729.       { "grfcl",    2195,    6},    /* Piccolo regs */
  10730.       /* MacroSystemsUS */
  10731.       { "wesc",    2203,    19},    /* Warp engine */
  10732.       /* phase 5 digital products? */
  10733. ***************
  10734. *** 118,133 ****
  10735.       /* Commodore Amiga */
  10736.       { "afsc",    514,    84},    /* A4091 SCSI HD Controller */
  10737.       /* Hacker Inc. */
  10738. !     { "mlhsc",    2011,    1 }
  10739.   };
  10740.   static int naconfent = sizeof(aconftab) / sizeof(struct aconfdata);
  10741.   
  10742.   /*
  10743.    * Anything listed in this table is subject to pre-configuration,
  10744.    * if autoconf.c:config_console() calls amiga_config_found() on
  10745. !  * the Zorro III device.
  10746.    */
  10747.   static struct preconfdata preconftab[] = {
  10748.       { 18260, 6, 0 },
  10749.       /* Retina BLT Z3 */
  10750.       { 18260, 16, 0},
  10751. --- 119,138 ----
  10752.       /* Commodore Amiga */
  10753.       { "afsc",    514,    84},    /* A4091 SCSI HD Controller */
  10754.       /* Hacker Inc. */
  10755. !     { "mlhsc",    2011,    1 },        /* Michael Hitch */
  10756. !     { "cross",    2011,    3 },        /* Mark Tomlinsen */
  10757. !     /* David Salamon */
  10758. !     { "ggbus",    2150,    1 }
  10759.   };
  10760.   static int naconfent = sizeof(aconftab) / sizeof(struct aconfdata);
  10761.   
  10762.   /*
  10763.    * Anything listed in this table is subject to pre-configuration,
  10764.    * if autoconf.c:config_console() calls amiga_config_found() on
  10765. !  * the zbus device.
  10766.    */
  10767.   static struct preconfdata preconftab[] = {
  10768. +     /* Retina BLT Z2 */
  10769.       { 18260, 6, 0 },
  10770.       /* Retina BLT Z3 */
  10771.       { 18260, 16, 0},
  10772. *** old-NetBSD/src/sys/arch/amiga/dev/zssc.c
  10773. --- NetBSD/src/sys/arch/amiga/dev/zssc.c
  10774. ***************
  10775. *** 79,85 ****
  10776.       DV_DULL, sizeof(struct siop_softc), NULL, 0 };
  10777.   
  10778.   /*
  10779. !  * if we are an PPI Zeus
  10780.    */
  10781.   int
  10782.   zsscmatch(pdp, cdp, auxp)
  10783. --- 79,85 ----
  10784.       DV_DULL, sizeof(struct siop_softc), NULL, 0 };
  10785.   
  10786.   /*
  10787. !  * if we are a PPI Zeus
  10788.    */
  10789.   int
  10790.   zsscmatch(pdp, cdp, auxp)
  10791. ***************
  10792. *** 130,135 ****
  10793. --- 130,136 ----
  10794.       sc->sc_isr.isr_intr = zssc_dmaintr;
  10795.       sc->sc_isr.isr_arg = sc;
  10796.       sc->sc_isr.isr_ipl = 6;
  10797. +     sc->sc_isr.isr_mapped_ipl = 3;
  10798.       add_isr(&sc->sc_isr);
  10799.   
  10800.       /*
  10801. *** old-NetBSD/src/sys/arch/amiga/include/mtpr.h
  10802. --- NetBSD/src/sys/arch/amiga/include/mtpr.h
  10803. ***************
  10804. *** 41,48 ****
  10805.    *
  10806.    *    @(#)mtpr.h    7.2 (Berkeley) 11/3/90
  10807.    */
  10808. ! #ifndef _MACHINE_MPTR_H_
  10809. ! #define _MACHINE_MPTR_H_
  10810.   
  10811.   #ifdef _KERNEL
  10812.   /*
  10813. --- 41,48 ----
  10814.    *
  10815.    *    @(#)mtpr.h    7.2 (Berkeley) 11/3/90
  10816.    */
  10817. ! #ifndef _MACHINE_MTPR_H_
  10818. ! #define _MACHINE_MTPR_H_
  10819.   
  10820.   #ifdef _KERNEL
  10821.   /*
  10822. ***************
  10823. *** 60,66 ****
  10824.   
  10825.   #define SIR_NET        0x1    /* call netintr */
  10826.   #define SIR_CLOCK    0x2    /* call softclock */
  10827. ! #define    SIR_CBACK    0x4    /* walk the sicallback-chain */
  10828.   
  10829.   #define siroff(x)    ssir &= ~(x)
  10830.   #define setsoftint()    (custom.intreq = INTF_SETCLR|INTF_SOFTINT)
  10831. --- 60,66 ----
  10832.   
  10833.   #define SIR_NET        0x1    /* call netintr */
  10834.   #define SIR_CLOCK    0x2    /* call softclock */
  10835. ! #define SIR_CBACK    0x4    /* walk the sicallback-chain */
  10836.   
  10837.   #define siroff(x)    ssir &= ~(x)
  10838.   #define setsoftint()    (custom.intreq = INTF_SETCLR|INTF_SOFTINT)
  10839. ***************
  10840. *** 68,74 ****
  10841.   #define setsoftnet()    (ssir |= SIR_NET, setsoftint())
  10842.   #define setsoftclock()    (ssir |= SIR_CLOCK, setsoftint())
  10843.   #define setsoftcback()    (ssir |= SIR_CBACK, setsoftint())
  10844.   #endif /* _KERNEL */
  10845.   
  10846. ! #endif /* !_MACHINE_MPTR_H_ */
  10847. --- 68,73 ----
  10848.   #define setsoftnet()    (ssir |= SIR_NET, setsoftint())
  10849.   #define setsoftclock()    (ssir |= SIR_CLOCK, setsoftint())
  10850.   #define setsoftcback()    (ssir |= SIR_CBACK, setsoftint())
  10851.   #endif /* _KERNEL */
  10852.   
  10853. ! #endif /* !_MACHINE_MTPR_H_ */
  10854. *** old-NetBSD/src/sys/arch/amiga/include/param.h
  10855. --- NetBSD/src/sys/arch/amiga/include/param.h
  10856. ***************
  10857. *** 149,200 ****
  10858.    */
  10859.   #include <machine/psl.h>
  10860.   
  10861. ! /*
  10862. !  * point to the custom.intenar and custom.intenaw respectively.
  10863. !  */
  10864. ! extern volatile unsigned short *amiga_intena_read, *amiga_intena_write;
  10865.   
  10866. ! #if 0
  10867. ! #define _debug_spl(s) \
  10868.   ({ \
  10869.           register int _spl_r; \
  10870.   \
  10871. !         __asm __volatile ("clrl %0; movew sr,%0; movew %1,sr" : \
  10872. !                 "&=d" (_spl_r) : "di" (s)); \
  10873. !     if ((_spl_r&PSL_IPL) > ((s)&PSL_IPL)&&((s)&PSL_IPL)!=PSL_IPL1) \
  10874. !         printf ("%s:%d:spl(%d) ==> spl(%d)!!\n",__FILE__,__LINE__, \
  10875. !             ((PSL_IPL&_spl_r)>>8), ((PSL_IPL&(s))>>8)); \
  10876.           _spl_r; \
  10877.   })
  10878. ! #else
  10879. ! /*
  10880. !  * Don't lower IPL below current IPL (unless new IPL is 6)
  10881. !  */
  10882. ! #define _debug_spl(s) \
  10883.   ({ \
  10884.           register int _spl_r; \
  10885.   \
  10886. !         __asm __volatile ("clrl %0; movew sr,%0" : \
  10887. !                 "&=d" (_spl_r)); \
  10888. !     if ((((s)&PSL_IPL) >= PSL_IPL6) || (_spl_r&PSL_IPL) < ((s)&PSL_IPL) || ((s)&PSL_IPL) <= PSL_IPL1) \
  10889. !         __asm __volatile ("movew %0,sr" : : "di" (s)); \
  10890.           _spl_r; \
  10891.   })
  10892.   #endif
  10893.   
  10894.   #define _spl_no_check(s) \
  10895.   ({ \
  10896.           register int _spl_r; \
  10897.   \
  10898. !         __asm __volatile ("clrl %0; movew sr,%0; movew %1,sr" : \
  10899. !                 "&=d" (_spl_r) : "di" (s)); \
  10900. !         _spl_r; \
  10901.   })
  10902. ! #if defined (DEBUGXX)        /* No workee */
  10903. ! #define _spl _debug_spl
  10904. ! #else
  10905. ! #define _spl _spl_no_check
  10906. ! #endif
  10907.   
  10908.   #define spl0()    _spl(PSL_S|PSL_IPL0)
  10909.   #define spl1()    _spl(PSL_S|PSL_IPL1)
  10910. --- 149,241 ----
  10911.    */
  10912.   #include <machine/psl.h>
  10913.   
  10914. ! #ifdef SPL_PROF
  10915.   
  10916. ! struct _spl_ent {
  10917. !     int    psw;
  10918. !     int    ticks;
  10919. !     int    usec;
  10920. ! };
  10921. ! #define _spl_push(s) \
  10922.   ({ \
  10923.           register int _spl_r; \
  10924.   \
  10925. !     __asm __volatile("clrl %0; movew sr,%0" : "=d" (_spl_r)); \
  10926. !     if (spl_prof || spl_debug) { \
  10927. !         if (spl_debug && (_spl_r & PSL_IPL) > (s & PSL_IPL)) \
  10928. !             printf ("%s:%d: unexpected lowering of spl" \
  10929. !                 " 0x%x to 0x%x\n", \
  10930. !                     __FILE__, __LINE__, _spl_r, s); \
  10931. !             _spl_p->psw = _spl_r; \
  10932. !         if (spl_prof) { \
  10933. !                 _spl_p->ticks = ticks; \
  10934. !                 _spl_p->usec = clkread(); \
  10935. !         } \
  10936. !             _spl_p++; \
  10937. !     } \
  10938. !     if ((isr_exter_ipl << 8) > (s & PSL_IPL)) \
  10939. !         walk_ipls(isr_exter_ipl, s); \
  10940. !         __asm __volatile("movew %0,sr" : : "di" (s)); \
  10941.           _spl_r; \
  10942.   })
  10943. ! #define _spl_pop(s) \
  10944.   ({ \
  10945. +     u_int elapsed; \
  10946.           register int _spl_r; \
  10947.   \
  10948. !         __asm __volatile("clrl %0; movew sr,%0" : "=d" (_spl_r)); \
  10949. !     if ((spl_prof || spl_debug) && _spl_p > _spl_stack) { \
  10950. !         _spl_p--; \
  10951. !         if (_spl_p->psw != s) { \
  10952. !             if (spl_debug) \
  10953. !                 printf ("%s:%d: unexpected spl 0x%x " \
  10954. !                     "(wanted 0x%x)\n", \
  10955. !                     __FILE__, __LINE__, s, _spl_p->psw); \
  10956. !             _spl_p++; \
  10957. !         } else if (spl_prof) { \
  10958. !                 elapsed = 10000 * (ticks - _spl_p->ticks) + \
  10959. !                 clkread() - _spl_p->usec; \
  10960. !                 if (elapsed > 100) \
  10961. !                 printf ( \
  10962. !                     "%s:%d: long spl (%d us) above 0x%x\n", \
  10963. !                     __FILE__, __LINE__, elapsed, s); \
  10964. !         } \
  10965. !     } \
  10966. !     if ((isr_exter_ipl << 8) > (s & PSL_IPL)) \
  10967. !         walk_ipls(isr_exter_ipl, s); \
  10968. !         __asm __volatile("movew %0,sr" : : "di" (s)); \
  10969.           _spl_r; \
  10970.   })
  10971. + #define _spl    _spl_push
  10972. + #define splx    _spl_pop
  10973. + #ifdef _KERNEL
  10974. + extern int ticks;
  10975. + extern int clkread();
  10976. + extern struct _spl_ent _spl_stack[], *_spl_p;
  10977. + extern int spl_debug, spl_prof;
  10978.   #endif
  10979.   
  10980. + #else /* SPL_PROF */
  10981.   #define _spl_no_check(s) \
  10982.   ({ \
  10983.           register int _spl_r; \
  10984.   \
  10985. !         __asm __volatile("clrl %0; movew sr,%0" : "=d" (_spl_r)); \
  10986. !     if ((isr_exter_ipl << 8) > (s & PSL_IPL)) \
  10987. !         walk_ipls(isr_exter_ipl, s); \
  10988. !         __asm __volatile("movew %0,sr" : : "di" (s)); \
  10989. !     _spl_r; \
  10990.   })
  10991. ! #define _spl    _spl_no_check
  10992. ! #define splx    _spl_no_check
  10993. ! #endif /* SPL_PROF */
  10994.   
  10995.   #define spl0()    _spl(PSL_S|PSL_IPL0)
  10996.   #define spl1()    _spl(PSL_S|PSL_IPL1)
  10997. ***************
  10998. *** 226,236 ****
  10999.   #define splsched()    spl4()
  11000.   #endif
  11001.   
  11002. - #define splx(s)         _spl_no_check(s)
  11003.   #ifdef _KERNEL
  11004.   void delay __P((int));
  11005.   void DELAY __P((int));
  11006.   #endif
  11007.   
  11008.   #endif /* !_MACHINE_PARAM_H_ */
  11009. --- 267,277 ----
  11010.   #define splsched()    spl4()
  11011.   #endif
  11012.   
  11013.   #ifdef _KERNEL
  11014.   void delay __P((int));
  11015.   void DELAY __P((int));
  11016. + extern int isr_exter_ipl;
  11017. + extern void walk_ipls __P((int, int));
  11018.   #endif
  11019.   
  11020.   #endif /* !_MACHINE_PARAM_H_ */
  11021. *** old-NetBSD/src/sys/arch/amiga/include/trap.h
  11022. --- NetBSD/src/sys/arch/amiga/include/trap.h
  11023. ***************
  11024. *** 1,4 ****
  11025. ! /*    $NetBSD: trap.h,v 1.8 1995/02/12 19:19:39 chopps Exp $    */
  11026.   
  11027.   #ifndef _MACHINE_TRAP_H_
  11028.   #define _MACHINE_TRAP_H_
  11029. --- 1,4 ----
  11030. ! /*    $NetBSD: trap.h,v 1.7 1994/10/26 02:06:42 cgd Exp $    */
  11031.   
  11032.   #ifndef _MACHINE_TRAP_H_
  11033.   #define _MACHINE_TRAP_H_
  11034. *** /dev/null
  11035. --- NetBSD/src/sys/arch/amiga/isa/ISA-HOWTO
  11036. ***************
  11037. *** 0 ****
  11038. --- 1,29 ----
  11039. + Move i386/isa/foo*.[ch] to amiga/isa possibly prepending 'isa' to the name
  11040. + Reflect possible filename change in the source
  11041. + Change include of i386/isa/isa_machdep.h to amiga/isa/isa_machdep.h
  11042. + Move possible other i386/isa/*.h files that are needed
  11043. + If there are inw, outw, insw or outsw think carefully if these are words
  11044. + that should be converted to host order or not.  I.e. if you're reading
  11045. + a device register holding a 16-bit flag word, you should convert it, but
  11046. + if you're reading raw data word-wise you should not.  The functions to
  11047. + do this are itohs for converting from isa to host order and htois for the
  11048. + other way round.
  11049. + Follow up if ia_maddr is used and change loads/stores to the suitable
  11050. + ldb, stb, ldw and stw inlines defined in isabusvar.h.  Think about conversion
  11051. + to host order for wordwide accesses.  If the driver uses bcopy for moves
  11052. + from/to shared memory then there's two bcopy versions called copy_to_isa
  11053. + and copy_from_isa for you to use instead.  These may have problems with
  11054. + alignment if the target & source can reside on differently aligned areas,
  11055. + i.e. target on odd address while source on even.  If you find such usages
  11056. + please tell me.  bzero of shared memory is called zero_isa.  Tell me if you
  11057. + need long versions of the load/store inlines.  Note that ia_maddr is a
  11058. + virtual address in the i386 context, but not in our way of seeing it.  Thus
  11059. + any kvtop calls can be removed.  I usually replace them with a cast to int.
  11060. + For those of you writing isa drivers from scratch, look at another isa
  11061. + driver as a template.
  11062. *** /dev/null
  11063. --- NetBSD/src/sys/arch/amiga/isa/ISA-TODO
  11064. ***************
  11065. *** 0 ****
  11066. --- 1,5 ----
  11067. + LKM versions
  11068. + Compile time option for using inline bridge-dependent code
  11069. + 1.0 version
  11070. *** /dev/null
  11071. --- NetBSD/src/sys/arch/amiga/isa/cross.c
  11072. ***************
  11073. *** 0 ****
  11074. --- 1,422 ----
  11075. + /*    $NetBSD: cross.c,v 1.0 1994/07/08 23:32:17 niklas Exp $    */
  11076. + /*
  11077. +  * Copyright (c) 1994 Niklas Hallqvist, Carsten Hammer
  11078. +  * All rights reserved.
  11079. +  *
  11080. +  * Redistribution and use in source and binary forms, with or without
  11081. +  * modification, are permitted provided that the following conditions
  11082. +  * are met:
  11083. +  * 1. Redistributions of source code must retain the above copyright
  11084. +  *    notice, this list of conditions and the following disclaimer.
  11085. +  * 2. Redistributions in binary form must reproduce the above copyright
  11086. +  *    notice, this list of conditions and the following disclaimer in the
  11087. +  *    documentation and/or other materials provided with the distribution.
  11088. +  * 3. All advertising materials mentioning features or use of this software
  11089. +  *    must display the following acknowledgement:
  11090. +  *      This product includes software developed by Christian E. Hopps.
  11091. +  * 4. The name of the author may not be used to endorse or promote products
  11092. +  *    derived from this software without specific prior written permission
  11093. +  *
  11094. +  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  11095. +  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  11096. +  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  11097. +  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  11098. +  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  11099. +  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  11100. +  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11101. +  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  11102. +  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  11103. +  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  11104. +  */
  11105. + #include <sys/param.h>
  11106. + #include <sys/device.h>
  11107. + #include <sys/kernel.h>
  11108. + #include <sys/malloc.h>
  11109. + #include <sys/syslog.h>
  11110. + #include <machine/cpu.h>
  11111. + #include <amiga/amiga/custom.h>
  11112. + #include <amiga/amiga/device.h>
  11113. + #include <amiga/amiga/isr.h>
  11114. + #include <amiga/dev/zbusvar.h>
  11115. + #include <dev/isa/isavar.h>
  11116. + #include <amiga/isa/isa_machdep.h>
  11117. + #include <amiga/isa/crossvar.h>
  11118. + #include <amiga/isa/crossreg.h>
  11119. + int crossdebug = 0;
  11120. + /* This static is OK because we only allow one ISA bus.  */
  11121. + /* static */ struct cross_device *crossp;
  11122. + void crossattach __P((struct device *, struct device *, void *));
  11123. + int crossmatch __P((struct device *, void *, void *));
  11124. + int crossprint __P((void *auxp, char *));
  11125. + void crossoutb __P((struct device *, int, u_char));
  11126. + u_char crossinb __P((struct device *, int));
  11127. + void crossoutw __P((struct device *, int, u_short));
  11128. + u_short crossinw __P((struct device *, int));
  11129. + void crossstb __P((struct device *, int, u_char));
  11130. + u_char crossldb __P((struct device *, int));
  11131. + void crossstw __P((struct device *, int, u_short));
  11132. + u_short crossldw __P((struct device *, int));
  11133. + #if 0
  11134. + void crossaddint __P((struct device *, int, int (*)(), void *,int));
  11135. + void crossremint __P((struct device *, int));
  11136. + #else
  11137. + void crossaddint __P((int, int, struct intrhand *));
  11138. + void crossremint __P((int));
  11139. + #endif
  11140. + struct cfdriver crosscd = {
  11141. +     NULL, "cross", crossmatch, crossattach, 
  11142. +     DV_DULL, sizeof(struct cross_device), 0
  11143. + };
  11144. + int
  11145. + crossmatch(parent, match, aux)
  11146. +     struct device *parent;
  11147. +     void *match, *aux;
  11148. + {
  11149. +     struct zbus_args *zap = aux;
  11150. +     /*
  11151. +      * Check manufacturer and product id.
  11152. +      */
  11153. +     if (zap->manid == 2011 && zap->prodid == 3)
  11154. +         return(1);
  11155. +     return(0);
  11156. + }
  11157. + void
  11158. + crossattach(pdp, dp, auxp)
  11159. +     struct device *pdp, *dp;
  11160. +     void *auxp;
  11161. + {
  11162. +     struct zbus_args *zap = auxp;
  11163. +     struct cross_device *cdp = (struct cross_device *)dp;
  11164. +     crossp = cdp;
  11165. +     bcopy(zap, &cdp->cd_zargs, sizeof(struct zbus_args));
  11166. +     cdp->cd_link.il_dev = dp;
  11167. +     cdp->cd_link.il_inb = crossinb;
  11168. +     cdp->cd_link.il_outb = crossoutb;
  11169. +     cdp->cd_link.il_inw = crossinw;
  11170. +     cdp->cd_link.il_outw = crossoutw;
  11171. +     cdp->cd_link.il_ldb = crossldb;
  11172. +     cdp->cd_link.il_stb = crossstb;
  11173. +     cdp->cd_link.il_ldw = crossldw;
  11174. +     cdp->cd_link.il_stw = crossstw;
  11175. +     cdp->cd_link.il_addint = crossaddint;
  11176. +     cdp->cd_link.il_remint = crossremint;
  11177. +     cdp->cd_imask = 1 << CROSS_MASTER;
  11178. +     /* Enable interrupts lazily in crossaddint.  */
  11179. +     CROSS_ENABLE_INTS(zap->va, 0);
  11180. +     /* Default 16 bit tranfer  */
  11181. +     *(volatile u_short *)(cdp->cd_zargs.va + CROSS_XLP_LATCH) = CROSS_SBHE; 
  11182. +     printf(": pa 0x%08x va 0x%08x size 0x%x\n", zap->pa, zap->va,
  11183. +             zap->size);
  11184. + #if 0
  11185. +     cdp->cd_isr.isr_intr = crossintr6;
  11186. +     cdp->cd_isr.isr_ipl = 6;
  11187. +     cdp->cd_isr.isr_mapped_ipl = 4;
  11188. +     add_isr(&cdp->cd_isr);
  11189. + #endif
  11190. +     /*
  11191. +      * attempt to configure the board.
  11192. +      */
  11193. +     config_found(dp, &cdp->cd_link, crossprint);
  11194. + }
  11195. + int
  11196. + crossprint(auxp, pnp)
  11197. +     void *auxp;
  11198. +     char *pnp;
  11199. + {
  11200. +     if (pnp == NULL)
  11201. +         return(QUIET);
  11202. +     return(UNCONF);
  11203. + }
  11204. + #if 0
  11205. + /* XXX We don't care about the priority yet, although we ought to.  */
  11206. + int
  11207. + crossintr6()
  11208. + {
  11209. +     struct cross_device *dev = crossp;
  11210. +     int ints;
  11211. +     int mine = 0;
  11212. +     int i;
  11213. +     int bit;
  11214. +     if (!crossp)
  11215. +         return 0;
  11216. +     ints = CROSS_GET_INT_STATUS(dev->cd_zargs.va) & dev->cd_imask;
  11217. +     while (ints) {
  11218. +         for (i = 0; bit = ffs(ints); ints >>= bit, i++) {
  11219. +             i += bit - 1;
  11220. +             if (!dev->cd_ifunc[i]) {
  11221. +                 log(LOG_WARNING,
  11222. +                     "Huh, cd_ifunc[%d] was zero (ints=0x%04x, mask=0x%04x)\n",
  11223. +                     i, ints, dev->cd_imask);
  11224. + #ifdef DDB
  11225. +                 /*
  11226. +                  * We better try to find out how this
  11227. +                  * happened
  11228. +                  */
  11229. +                 Debugger();
  11230. + #endif
  11231. +             } else {
  11232. +                 (*dev->cd_ifunc[i])(dev->cd_iarg[i]);
  11233. +                 mine = 1;
  11234. +             }
  11235. +         }
  11236. +         ints = CROSS_GET_INT_STATUS(dev->cd_zargs.va) & dev->cd_imask;
  11237. +     }
  11238. +     return mine;
  11239. + }
  11240. + #endif
  11241. + void
  11242. + crossoutb(dev, ia, b)
  11243. +     struct device *dev;
  11244. +     int ia;
  11245. +     u_char b;
  11246. + {
  11247. +     struct cross_device *cd = (struct cross_device *)dev;
  11248. + #ifdef DEBUG
  11249. +     if (crossdebug)
  11250. +         printf("outb 0x%x,0x%x\n", ia, b);
  11251. + #endif
  11252. +     
  11253. +     *(volatile u_char *)(cd->cd_zargs.va + 2 * ia) = b;
  11254. + }
  11255. + u_char
  11256. + crossinb(dev, ia)
  11257. +     struct device *dev;
  11258. +     int ia;
  11259. + {
  11260. +     struct cross_device *cd = (struct cross_device *)dev;
  11261. + #ifdef DEBUG
  11262. +     u_char retval = *(volatile u_char *)(cd->cd_zargs.va + 2 * ia);
  11263. +     if (crossdebug)
  11264. +         printf("inb 0x%x => 0x%x\n", ia, retval);
  11265. +     return retval;
  11266. + #else
  11267. +     return *(volatile u_char *)(cd->cd_zargs.va + 2 * ia);
  11268. + #endif
  11269. + }
  11270. + void
  11271. + crossoutw(dev, ia, w)
  11272. +     struct device *dev;
  11273. +     int ia;
  11274. +     u_short w;
  11275. + {
  11276. +     struct cross_device *cd = (struct cross_device *)dev;
  11277. + #ifdef DEBUG
  11278. +     if (crossdebug)
  11279. +         printf("outw 0x%x,0x%x\n", ia, w);
  11280. + #endif
  11281. +     *(volatile u_short *)(cd->cd_zargs.va + 2 * ia) = w;
  11282. + }
  11283. + u_short
  11284. + crossinw(dev, ia)
  11285. +     struct device *dev;
  11286. +     int ia;
  11287. + {
  11288. +     struct cross_device *cd = (struct cross_device *)dev;
  11289. +     u_short retval = *(volatile u_short *)(cd->cd_zargs.va + 2 * ia);
  11290. + #ifdef DEBUG
  11291. +     if (crossdebug)
  11292. +         printf("inw 0x%x => 0x%x\n", ia, retval);
  11293. + #endif
  11294. +     return retval;
  11295. + }
  11296. + void
  11297. + crossstb(dev, ia, b)
  11298. +     struct device *dev;
  11299. +     int ia;
  11300. +     u_char b;
  11301. + {
  11302. +     /* generate A13-A19 for correct page */
  11303. +     u_short upper_addressbits = ia >> 13;
  11304. +     struct cross_device *cd = (struct cross_device *)dev;
  11305. +     *(volatile u_short *)(cd->cd_zargs.va + CROSS_XLP_LATCH) =
  11306. +         upper_addressbits | CROSS_SBHE;
  11307. +     *(volatile u_char *)(cd->cd_zargs.va + CROSS_MEMORY_OFFSET + 2 * ia) =
  11308. +         b;
  11309. + }
  11310. + u_char
  11311. + crossldb(dev, ia)
  11312. +     struct device *dev;
  11313. +     int ia;
  11314. + {
  11315. +     /* generate A13-A19 for correct page */
  11316. +     u_short upper_addressbits = ia >> 13;
  11317. +     struct cross_device *cd = (struct cross_device *)dev;
  11318. +     *(volatile u_short *)(cd->cd_zargs.va + CROSS_XLP_LATCH) =
  11319. +         upper_addressbits | CROSS_SBHE;
  11320. +     return *(volatile u_char *)(cd->cd_zargs.va + CROSS_MEMORY_OFFSET +
  11321. +             2 * ia);
  11322. + }
  11323. + void
  11324. + crossstw(dev, ia, w)
  11325. +     struct device *dev;
  11326. +     int ia;
  11327. +     u_short w;
  11328. + {
  11329. +     /* generate A13-A19 for correct page */
  11330. +     u_short upper_addressbits = ia >> 13;
  11331. +     struct cross_device *cd = (struct cross_device *)dev;
  11332. +      
  11333. +     *(volatile u_short *)(cd->cd_zargs.va + CROSS_XLP_LATCH) =
  11334. +         upper_addressbits | CROSS_SBHE;
  11335. + #ifdef DEBUG
  11336. +     if (crossdebug)
  11337. +         printf("outw 0x%x,0x%x\n", ia, w);
  11338. + #endif
  11339. +     *(volatile u_short *)(cd->cd_zargs.va + CROSS_MEMORY_OFFSET + 2 * ia) =
  11340. +         w;
  11341. + }
  11342. + u_short
  11343. + crossldw(dev, ia)
  11344. +     struct device *dev;
  11345. +     int ia;
  11346. + {
  11347. +     /* generate A13-A19 for correct page */
  11348. +     u_short upper_addressbits = ia >> 13;
  11349. +     struct cross_device *cd = (struct cross_device *)dev;
  11350. +     u_short retval;
  11351. +     *(volatile u_short *)(cd->cd_zargs.va + CROSS_XLP_LATCH) =
  11352. +         upper_addressbits | CROSS_SBHE;
  11353. +     retval = *(volatile u_short *)(cd->cd_zargs.va + CROSS_MEMORY_OFFSET +
  11354. +         2 * ia);
  11355. + #ifdef DEBUG
  11356. +     if (crossdebug)
  11357. +         printf("ldw 0x%x => 0x%x\n", ia, retval);
  11358. + #endif
  11359. +     return retval;
  11360. + }
  11361. + static cross_int_map[] = {
  11362. +     0, 0, 0, 0, CROSS_IRQ3, CROSS_IRQ4, CROSS_IRQ5, CROSS_IRQ6, CROSS_IRQ7, 0,
  11363. +     CROSS_IRQ9, CROSS_IRQ10, CROSS_IRQ11, CROSS_IRQ12, 0, CROSS_IRQ14,
  11364. +     CROSS_IRQ15
  11365. + };
  11366. + #if 0
  11367. + /* XXX We don't care about the priority yet, although we ought to.  */
  11368. + void
  11369. + crossaddint(dev, irq, func, arg, pri)
  11370. +     struct device *dev;
  11371. +     int irq;
  11372. +     int (*func)();
  11373. +     void *arg;
  11374. +     int pri;
  11375. + {
  11376. +     struct cross_device *cd = (struct cross_device *)dev;
  11377. +     int s = splhigh();
  11378. +     int bit = cross_int_map[irq + 1];
  11379. +     if (!bit) {
  11380. +         log(LOG_WARNING, "Registration of unknown ISA interrupt %d\n",
  11381. +             irq);
  11382. +         goto out;
  11383. +     }
  11384. +     if (cd->cd_imask & 1 << bit) {
  11385. +         log(LOG_WARNING, "ISA interrupt %d already handled\n", irq);
  11386. +         goto out;
  11387. +     }
  11388. +     cd->cd_imask |= (1 << bit);
  11389. +         CROSS_ENABLE_INTS (cd->cd_zargs.va, cd->cd_imask);
  11390. +     cd->cd_ifunc[bit] = func;
  11391. +     cd->cd_ipri[bit] = pri;
  11392. +     cd->cd_iarg[bit] = arg;
  11393. + out:
  11394. +     splx(s);
  11395. + }
  11396. + void
  11397. + crossremint(dev, irq)
  11398. +     struct device *dev;
  11399. +     int irq;
  11400. + {
  11401. +     struct cross_device *cd = (struct cross_device *)dev;
  11402. +     int s = splhigh();
  11403. +     int bit = cross_int_map[irq + 1];
  11404. +     cd->cd_imask &= ~(1 << bit);
  11405. +         CROSS_ENABLE_INTS (cd->cd_zargs.va, cd->cd_imask);
  11406. +     splx(s);
  11407. + }
  11408. + #else
  11409. + struct crossintr_desc {
  11410. +     struct    isr cid_isr;
  11411. +     int    cid_mask;
  11412. +     struct    intrhand *cid_ih;
  11413. + };
  11414. + static struct crossintr_desc *crid[16];    /* XXX */
  11415. + int
  11416. + crossintr(cid)
  11417. +     struct crossintr_desc *cid;
  11418. + {
  11419. +     return (CROSS_GET_STATUS (crossp->cd_zargs.va) & cid->cid_mask) ?
  11420. +         (*cid->cid_ih->ih_fun)(cid->cid_ih->ih_arg) : 0;
  11421. + }
  11422. + void
  11423. + crossaddint(irq, type, ih)
  11424. +     int irq;
  11425. +     int type;
  11426. +     struct intrhand *ih;
  11427. + {
  11428. +     if (crid[irq]) {
  11429. +         log(LOG_WARNING, "ISA interrupt %d already handled\n", irq);
  11430. +         return;
  11431. +     }
  11432. +     MALLOC(crid[irq], struct crossintr_desc *,
  11433. +         sizeof(struct crossintr_desc), M_DEVBUF, M_WAITOK);
  11434. +     crid[irq]->cid_isr.isr_intr = crossintr;
  11435. +     crid[irq]->cid_isr.isr_arg = crid[irq];
  11436. +     crid[irq]->cid_isr.isr_ipl = 6;
  11437. +     crid[irq]->cid_isr.isr_mapped_ipl = ih->ih_level;
  11438. +     crid[irq]->cid_mask = 1 << cross_int_map[irq + 1];
  11439. +     crid[irq]->cid_ih = ih;
  11440. +     add_isr (&crid[irq]->cid_isr);
  11441. +     crossp->cd_imask |= 1 << cross_int_map[irq + 1];
  11442. +         CROSS_ENABLE_INTS (crossp->cd_zargs.va, crossp->cd_imask);
  11443. + }
  11444. + void
  11445. + crossremint(irq)
  11446. +     int irq;
  11447. + {
  11448. +     remove_isr(&crid[irq]->cid_isr);
  11449. +     FREE(crid[irq], M_DEVBUF);
  11450. +     crid[irq] = 0;
  11451. +     crossp->cd_imask &= ~(1 << cross_int_map[irq + 1]);
  11452. +         CROSS_ENABLE_INTS (crossp->cd_zargs.va, crossp->cd_imask);
  11453. + }
  11454. + #endif
  11455. *** /dev/null
  11456. --- NetBSD/src/sys/arch/amiga/isa/crossreg.h
  11457. ***************
  11458. *** 0 ****
  11459. --- 1,133 ----
  11460. + /*    $NetBSD: crossreg.h,v 1.1 1994/07/08 23:32:17 niklas Exp $    */
  11461. + /*
  11462. +  * Copyright (c) 1994 Niklas Hallqvist, Carsten Hammer
  11463. +  * All rights reserved.
  11464. +  *
  11465. +  * Redistribution and use in source and binary forms, with or without
  11466. +  * modification, are permitted provided that the following conditions
  11467. +  * are met:
  11468. +  * 1. Redistributions of source code must retain the above copyright
  11469. +  *    notice, this list of conditions and the following disclaimer.
  11470. +  * 2. Redistributions in binary form must reproduce the above copyright
  11471. +  *    notice, this list of conditions and the following disclaimer in the
  11472. +  *    documentation and/or other materials provided with the distribution.
  11473. +  * 3. All advertising materials mentioning features or use of this software
  11474. +  *    must display the following acknowledgement:
  11475. +  *      This product includes software developed by Christian E. Hopps.
  11476. +  * 4. The name of the author may not be used to endorse or promote products
  11477. +  *    derived from this software without specific prior written permission
  11478. +  *
  11479. +  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  11480. +  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  11481. +  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  11482. +  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  11483. +  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  11484. +  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  11485. +  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11486. +  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  11487. +  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  11488. +  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  11489. +  */
  11490. + #ifndef _CROSSREG_H_
  11491. + #define _CROSSREG_H_
  11492. + /***
  11493. + * 
  11494. + *
  11495. + * Hardware description:
  11496. + *
  11497. + *  The CrossLink board is a 64K autoconfig device. The board address can be
  11498. + *  read from the xlink.resource structure instead of searching with the
  11499. + *  expansion library. In this way, the manufacturer ID is not required by
  11500. + *  the software developer.
  11501. + *
  11502. + *  Address mapping is as follows:
  11503. + *   XL_ROM     16K of byte wide ROM appearing at even locations.
  11504. + *              Used to hold the xlink.resource, and any autobooting
  11505. + *              devices.
  11506. + *   XL_MEM     Memory space. For 8 bit cards, bytes appear at even
  11507. + *              locations, (ie multiply address by 2). For 16 bit cards,
  11508. + *              words appear at long word boundaries (ie multiply by
  11509. + *              2). You can read bytes from 16 bit cards - odd bytes
  11510. + *              will appear at odd locations. SBHE must be set to the
  11511. + *              appropriate value for this. Multiple pages are accessible
  11512. + *              via the page register (see MemPage register).
  11513. + *   XL_IO      I/O space. 8K of I/O space is supported by the hardware,
  11514. + *              however only 1K is managed by this resource (as IBM's
  11515. + *              *never* have cards which decode more I/O space than this).
  11516. + *              You should AllocPortSpace() the area you want to use to
  11517. + *              get exclusive access before using the I/O. 8/16 bit cards
  11518. + *              read/write bytes/words at word boundaries. (You should know
  11519. + *              whether the port is 8 or 16 bits wide).
  11520. + *
  11521. + * Within the 1K I/O space, there are some 8 and 16 bit registers on the
  11522. + * xlink board itself. These registers are normally only accessed by
  11523. + * the xlink.resource, they are only described here for completeness.
  11524. + * Later revisions of the CrossLink board may move/change the meaning
  11525. + * of these registers. They are as follows:
  11526. + * (actual address = SBP_xxxx + SB_IO + board address)
  11527. + *
  11528. + *   XLP_LATCH  (Write Only) (offset = 2)
  11529. + *              Latches most significant address lines. D0-D6 contain the
  11530. + *              values for the most significant 7 address lines (A13-A19).
  11531. + *              D7 contains data for SBHE line (always 1 for 8 bit transfers
  11532. + *              on 8 bit boards, and 16 bit transfers on 16 bit boards.
  11533. + *              Set SBHE to 0 to perform 8 bit transfers on 16 bit boards).
  11534. + *
  11535. + *   XLP_INTABLE (Write Only) (offset = 0)
  11536. + *              Interrupt Enable & Disable. Bits map to the interrupts in
  11537. + *              the following manner:
  11538. + *                Data   Interrupt          Data   Interrupt
  11539. + *                 2        10               10       2
  11540. + *                 3        11               11       3
  11541. + *                 4        12               12       4
  11542. + *                 5        Master           13       5
  11543. + *                 6        14               14       6
  11544. + *                 7        15               15       7
  11545. + *              Unused bits should not be interpreted in any way. When
  11546. + *              writing to this register, unused bits should be zero. This
  11547. + *              register should only be used by the xlink.resource.
  11548. + *
  11549. + *   XLP_INTSTAT (Read Only) (offset = 0)
  11550. + *              Interrupt Status. Bit mapping is the same as the
  11551. + *              XLP_INTABLE location. Normally you only need to add your
  11552. + *              interrupt handler to the appropriate port, and not worry
  11553. + *              about this register. However, it can be also used to
  11554. + *              determine which interrupt a board is connected to. 
  11555. + **/
  11556. + /* hardware offsets from config address */
  11557. + #define CROSS_XL_ROM          0x8000
  11558. + #define CROSS_XL_MEM          0x4000
  11559. + #define CROSS_XL_IO           0x0000
  11560. + #define CROSS_XLP_INTSTAT 0
  11561. + #define CROSS_XLP_INTABLE 0
  11562. + #define CROSS_XLP_LATCH 2
  11563. + #define CROSS_MEMORY_OFFSET (CROSS_XL_MEM - 2 * 0x90000)
  11564. + #define CROSS_SBHE 0x40
  11565. + #define CROSS_GET_STATUS(va) \
  11566. +     (*(volatile u_short *)((va) + CROSS_XLP_INTSTAT))
  11567. + #define CROSS_MASTER 5
  11568. + /* From what I understand IRQ2 is really IRQ9 -NH */
  11569. + #define CROSS_IRQ9 10
  11570. + #define CROSS_IRQ3 11
  11571. + #define CROSS_IRQ4 12
  11572. + #define CROSS_IRQ5 13
  11573. + #define CROSS_IRQ6 14
  11574. + #define CROSS_IRQ7 15
  11575. + #define CROSS_IRQ10 2
  11576. + #define CROSS_IRQ11 3
  11577. + #define CROSS_IRQ12 4
  11578. + #define CROSS_IRQ14 6
  11579. + #define CROSS_IRQ15 7
  11580. + #define CROSS_IRQMASK 0xfcdc
  11581. + #define CROSS_GET_INT_STATUS(va) (CROSS_GET_STATUS(va) & CROSS_IRQMASK)
  11582. + #define CROSS_ENABLE_INTS(va, ints) \
  11583. +     (*(volatile u_short *)((va) + CROSS_XLP_INTABLE) = ints) 
  11584. + #endif
  11585. *** /dev/null
  11586. --- NetBSD/src/sys/arch/amiga/isa/crossvar.h
  11587. ***************
  11588. *** 0 ****
  11589. --- 1,46 ----
  11590. + /*    $NetBSD: crossvar.h,v 1.1 1994/07/08 23:32:17 niklas Exp $    */
  11591. + /*
  11592. +  * Copyright (c) 1994 Niklas Hallqvist
  11593. +  * All rights reserved.
  11594. +  *
  11595. +  * Redistribution and use in source and binary forms, with or without
  11596. +  * modification, are permitted provided that the following conditions
  11597. +  * are met:
  11598. +  * 1. Redistributions of source code must retain the above copyright
  11599. +  *    notice, this list of conditions and the following disclaimer.
  11600. +  * 2. Redistributions in binary form must reproduce the above copyright
  11601. +  *    notice, this list of conditions and the following disclaimer in the
  11602. +  *    documentation and/or other materials provided with the distribution.
  11603. +  * 3. All advertising materials mentioning features or use of this software
  11604. +  *    must display the following acknowledgement:
  11605. +  *      This product includes software developed by Christian E. Hopps.
  11606. +  * 4. The name of the author may not be used to endorse or promote products
  11607. +  *    derived from this software without specific prior written permission
  11608. +  *
  11609. +  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  11610. +  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  11611. +  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  11612. +  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  11613. +  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  11614. +  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  11615. +  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11616. +  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  11617. +  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  11618. +  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  11619. +  */
  11620. + #ifndef _CROSSVAR_H_
  11621. + #define _CROSSVAR_H_
  11622. + struct cross_device {
  11623. +     struct    device cd_dev;
  11624. +     struct    zbus_args cd_zargs;
  11625. +     struct    isa_link cd_link;
  11626. +     int    (*cd_ifunc[16])();
  11627. +     void    *cd_iarg[16];
  11628. +     int    cd_ipri[16];
  11629. +     int    cd_imask;
  11630. +     struct    isr cd_isr;
  11631. + };
  11632. + #endif
  11633. *** /dev/null
  11634. --- NetBSD/src/sys/arch/amiga/isa/ggbus.c
  11635. ***************
  11636. *** 0 ****
  11637. --- 1,261 ----
  11638. + /*    $NetBSD: ggbus.c,v 1.1 1994/07/08 23:32:17 niklas Exp $    */
  11639. + /*
  11640. +  * Copyright (c) 1994, 1995 Niklas Hallqvist
  11641. +  * All rights reserved.
  11642. +  *
  11643. +  * Redistribution and use in source and binary forms, with or without
  11644. +  * modification, are permitted provided that the following conditions
  11645. +  * are met:
  11646. +  * 1. Redistributions of source code must retain the above copyright
  11647. +  *    notice, this list of conditions and the following disclaimer.
  11648. +  * 2. Redistributions in binary form must reproduce the above copyright
  11649. +  *    notice, this list of conditions and the following disclaimer in the
  11650. +  *    documentation and/or other materials provided with the distribution.
  11651. +  * 3. All advertising materials mentioning features or use of this software
  11652. +  *    must display the following acknowledgement:
  11653. +  *      This product includes software developed by Niklas Hallqvist.
  11654. +  * 4. The name of the author may not be used to endorse or promote products
  11655. +  *    derived from this software without specific prior written permission
  11656. +  *
  11657. +  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  11658. +  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  11659. +  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  11660. +  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  11661. +  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  11662. +  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  11663. +  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11664. +  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  11665. +  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  11666. +  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  11667. +  */
  11668. + #include <sys/param.h>
  11669. + #include <sys/device.h>
  11670. + #include <sys/kernel.h>
  11671. + #include <sys/malloc.h>
  11672. + #include <sys/syslog.h>
  11673. + #include <machine/cpu.h>
  11674. + #include <machine/pio.h>
  11675. + #include <dev/isa/isavar.h>
  11676. + #include <amiga/amiga/custom.h>
  11677. + #include <amiga/amiga/device.h>
  11678. + #include <amiga/amiga/isr.h>
  11679. + #include <amiga/dev/zbusvar.h>
  11680. + #include <amiga/isa/isa_machdep.h>
  11681. + #include <amiga/isa/isa_intr.h>
  11682. + #include <amiga/isa/ggbusvar.h>
  11683. + #include <amiga/isa/ggbusreg.h>
  11684. + int ggdebug = 0;
  11685. + int ggstrayints = 0;
  11686. + /* This is OK because we only allow one ISA bus.  */
  11687. + struct ggbus_device *ggbusp;
  11688. + void    ggbusattach __P((struct device *, struct device *, void *));
  11689. + int    ggbusmatch __P((struct device *, void *, void *));
  11690. + int    ggbusprint __P((void *auxp, char *));
  11691. + void    ggbusstb __P((struct device *, int, u_char));
  11692. + u_char    ggbusldb __P((struct device *, int));
  11693. + void    ggbusstw __P((struct device *, int, u_short));
  11694. + u_short ggbusldw __P((struct device *, int));
  11695. + void    *ggbus_establish_intr __P((int intr, isa_intrtype type,
  11696. +                    isa_intrlevel level,
  11697. +                    int (*ih_fun) (void *), void *));
  11698. + void    ggbus_disestablish_intr __P((void *handler));
  11699. + struct isa_intr_fcns ggbus_intr_fcns = {
  11700. +     0 /* ggbus_intr_setup */,    ggbus_establish_intr,
  11701. +     ggbus_disestablish_intr,    0 /* ggbus_iointr */
  11702. + };
  11703. + struct cfdriver ggbuscd = {
  11704. +     NULL, "ggbus", ggbusmatch, ggbusattach, 
  11705. +     DV_DULL, sizeof(struct ggbus_device), 0
  11706. + };
  11707. + int
  11708. + ggbusmatch(parent, match, aux)
  11709. +     struct device *parent;
  11710. +     void *match, *aux;
  11711. + {
  11712. +     struct zbus_args *zap = aux;
  11713. +     /*
  11714. +      * Check manufacturer and product id.
  11715. +      */
  11716. +     if (zap->manid == 2150 && zap->prodid == 1)
  11717. +         return(1);
  11718. +     return(0);
  11719. + }
  11720. + void
  11721. + ggbusattach(pdp, dp, auxp)
  11722. +     struct device *pdp, *dp;
  11723. +     void *auxp;
  11724. + {
  11725. +     struct zbus_args *zap = auxp;
  11726. +     struct ggbus_device *gdp = (struct ggbus_device *)dp;
  11727. +     ggbusp = gdp;
  11728. +     bcopy(zap, &gdp->gd_zargs, sizeof(struct zbus_args));
  11729. +     gdp->gd_link.il_dev = dp;
  11730. +     if (gdp->gd_zargs.serno >= 2)
  11731. +       {
  11732. +         gdp->gd_link.il_ldb = ggbusldb;
  11733. +         gdp->gd_link.il_stb = ggbusstb;
  11734. +         gdp->gd_link.il_ldw = ggbusldw;
  11735. +         gdp->gd_link.il_stw = ggbusstw;
  11736. +       }
  11737. +     else
  11738. +       {
  11739. +         gdp->gd_link.il_ldb = 0;
  11740. +         gdp->gd_link.il_stb = 0;
  11741. +         gdp->gd_link.il_ldw = 0;
  11742. +         gdp->gd_link.il_stw = 0;
  11743. +       }
  11744. +     gdp->gd_imask = 0;
  11745. +     isa_intr_fcns = &ggbus_intr_fcns;
  11746. +     isa_pio_fcns = &ggbus_pio_fcns;
  11747. +     if (gdp->gd_zargs.serno >= 2)
  11748. +       {
  11749. +         /* XXX turn on wait states unconditionally for now. */
  11750. +         GG2_ENABLE_WAIT(zap->va);
  11751. +         GG2_ENABLE_INTS(zap->va);
  11752. +       }
  11753. +     printf(": pa 0x%08x va 0x%08x size 0x%x\n", zap->pa, zap->va, zap->size);
  11754. +     /*
  11755. +      * attempt to configure the board.
  11756. +      */
  11757. +     config_found(dp, &gdp->gd_link, ggbusprint);
  11758. + }
  11759. + int
  11760. + ggbusprint(auxp, pnp)
  11761. +     void *auxp;
  11762. +     char *pnp;
  11763. + {
  11764. +     if (pnp == NULL)
  11765. +         return(QUIET);
  11766. +     return(UNCONF);
  11767. + }
  11768. + void
  11769. + ggbusstb(dev, ia, b)
  11770. +     struct device *dev;
  11771. +     int ia;
  11772. +     u_char b;
  11773. + {
  11774. +     struct ggbus_device *gd = (struct ggbus_device *)dev;
  11775. +     *(volatile u_char *)(gd->gd_zargs.va + GG2_MEMORY_OFFSET + 2 * ia + 1) = b;
  11776. + }
  11777. + u_char
  11778. + ggbusldb(dev, ia)
  11779. +     struct device *dev;
  11780. +     int ia;
  11781. + {
  11782. +     struct ggbus_device *gd = (struct ggbus_device *)dev;
  11783. +     u_char retval =
  11784. +         *(volatile u_char *)(gd->gd_zargs.va + GG2_MEMORY_OFFSET + 2 * ia + 1);
  11785. + #ifdef DEBUG
  11786. +     if (ggdebug)
  11787. +         printf("ldb 0x%x => 0x%x\n", ia, retval);
  11788. + #endif
  11789. +     return retval;
  11790. + }
  11791. + void
  11792. + ggbusstw(dev, ia, w)
  11793. +     struct device *dev;
  11794. +     int ia;
  11795. +     u_short w;
  11796. + {
  11797. +     struct ggbus_device *gd = (struct ggbus_device *)dev;
  11798. +     *(volatile u_short *)(gd->gd_zargs.va + GG2_MEMORY_OFFSET + 2 * ia) = swap(w);
  11799. + }
  11800. + u_short
  11801. + ggbusldw(dev, ia)
  11802. +     struct device *dev;
  11803. +     int ia;
  11804. + {
  11805. +     struct ggbus_device *gd = (struct ggbus_device *)dev;
  11806. +     u_short retval =
  11807. +         swap(*(volatile u_short *)(gd->gd_zargs.va + GG2_MEMORY_OFFSET + 2 * ia));
  11808. + #ifdef DEBUG
  11809. +     if (ggdebug)
  11810. +         printf("ldw 0x%x => 0x%x\n", ia, retval);
  11811. + #endif
  11812. +     return retval;
  11813. + }
  11814. + static ggbus_int_map[] = {
  11815. +     0, 0, 0, 0, GG2_IRQ3, GG2_IRQ4, GG2_IRQ5, GG2_IRQ6, GG2_IRQ7, 0,
  11816. +     GG2_IRQ9, GG2_IRQ10, GG2_IRQ11, GG2_IRQ12, 0, GG2_IRQ14, GG2_IRQ15
  11817. + };
  11818. + struct ggintr_desc {
  11819. +     struct    isr gid_isr;
  11820. +     int    gid_mask;
  11821. +     int    (*gid_fun)(void *);
  11822. +     void    *gid_arg;
  11823. + };
  11824. + static struct ggintr_desc *ggid[16];    /* XXX */
  11825. + int
  11826. + ggbusintr(gid)
  11827. +     struct ggintr_desc *gid;
  11828. + {
  11829. +     return (GG2_GET_STATUS (ggbusp->gd_zargs.va) & gid->gid_mask) ?
  11830. +         (*gid->gid_fun)(gid->gid_arg) : 0;
  11831. + }
  11832. + void *
  11833. + ggbus_establish_intr(intr, type, level, ih_fun, ih_arg)
  11834. +     int intr;
  11835. +     isa_intrtype type;
  11836. +     isa_intrlevel level;
  11837. +     int (*ih_fun)(void *);
  11838. +     void *ih_arg;
  11839. + {
  11840. +     if (ggid[intr]) {
  11841. +         log(LOG_WARNING, "ISA interrupt %d already handled\n", intr);
  11842. +         return 0;
  11843. +     }
  11844. +     MALLOC(ggid[intr], struct ggintr_desc *, sizeof(struct ggintr_desc),
  11845. +         M_DEVBUF, M_WAITOK);
  11846. +     ggid[intr]->gid_isr.isr_intr = ggbusintr;
  11847. +     ggid[intr]->gid_isr.isr_arg = ggid[intr];
  11848. +     ggid[intr]->gid_isr.isr_ipl = 6;
  11849. +     ggid[intr]->gid_isr.isr_mapped_ipl = level;
  11850. +     ggid[intr]->gid_mask = 1 << ggbus_int_map[intr + 1];
  11851. +     ggid[intr]->gid_fun = ih_fun;
  11852. +     ggid[intr]->gid_arg = ih_arg;
  11853. +     add_isr(&ggid[intr]->gid_isr);
  11854. +     return &ggid[intr];
  11855. + }
  11856. + void
  11857. + ggbus_disestablish_intr(handler)
  11858. +     void  *handler;
  11859. + {
  11860. +     struct ggintr_desc **gid = handler;
  11861. +     remove_isr(&(*gid)->gid_isr);
  11862. +     FREE(*gid, M_DEVBUF);
  11863. +     *gid = 0;
  11864. + }
  11865. *** /dev/null
  11866. --- NetBSD/src/sys/arch/amiga/isa/ggbus_pio.c
  11867. ***************
  11868. *** 0 ****
  11869. --- 1,114 ----
  11870. + /*    $NetBSD: ggbus_pio.c,v 1.1 1995/08/04 14:32:17 niklas Exp $    */
  11871. + /*
  11872. +  * Copyright (c) 1995 Niklas Hallqvist
  11873. +  * All rights reserved.
  11874. +  *
  11875. +  * Redistribution and use in source and binary forms, with or without
  11876. +  * modification, are permitted provided that the following conditions
  11877. +  * are met:
  11878. +  * 1. Redistributions of source code must retain the above copyright
  11879. +  *    notice, this list of conditions and the following disclaimer.
  11880. +  * 2. Redistributions in binary form must reproduce the above copyright
  11881. +  *    notice, this list of conditions and the following disclaimer in the
  11882. +  *    documentation and/or other materials provided with the distribution.
  11883. +  * 3. All advertising materials mentioning features or use of this software
  11884. +  *    must display the following acknowledgement:
  11885. +  *      This product includes software developed by Niklas Hallqvist.
  11886. +  * 4. The name of the author may not be used to endorse or promote products
  11887. +  *    derived from this software without specific prior written permission
  11888. +  *
  11889. +  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  11890. +  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  11891. +  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  11892. +  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  11893. +  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  11894. +  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  11895. +  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11896. +  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  11897. +  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  11898. +  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  11899. +  */
  11900. + #include <sys/types.h>
  11901. + #include <sys/device.h>
  11902. + #include <machine/pio.h>
  11903. + #include <dev/isa/isavar.h>
  11904. + #include <amiga/amiga/isr.h>
  11905. + #include <amiga/dev/zbusvar.h>
  11906. + #include <amiga/isa/isa_machdep.h>
  11907. + #include <amiga/isa/ggbusreg.h>
  11908. + #include <amiga/isa/ggbusvar.h>
  11909. + extern struct ggbus_device *ggbusp;
  11910. + void        ggbus_outb __P((int, u_int8_t));
  11911. + u_int8_t    ggbus_inb __P((int));
  11912. + void        ggbus_outw __P((int, u_int16_t));
  11913. + u_int16_t    ggbus_inw __P((int));
  11914. + struct isa_pio_fcns ggbus_pio_fcns = {
  11915. +     ggbus_inb,    isa_insb,
  11916. +     ggbus_inw,    isa_insw,
  11917. +     0 /* ggbus_inl */,    0 /* ggbus_insl */,
  11918. +     ggbus_outb,    isa_outsb,
  11919. +     ggbus_outw,    isa_outsw,
  11920. +     0 /* ggbus_outl */,    0 /* ggbus_outsl */,
  11921. + };
  11922. + void
  11923. + ggbus_outb(ia, b)
  11924. +     int ia;
  11925. +     u_int8_t b;
  11926. + {
  11927. + #ifdef DEBUG
  11928. +     if (ggdebug)
  11929. +         printf("outb 0x%x,0x%x\n", ia, b);
  11930. + #endif
  11931. +     *(volatile u_int8_t *)(ggbusp->gd_zargs.va + 2 * ia + 1) = b;
  11932. + }
  11933. + u_int8_t
  11934. + ggbus_inb(ia)
  11935. +     int ia;
  11936. + {
  11937. +     u_int8_t retval =
  11938. +         *(volatile u_int8_t *)(ggbusp->gd_zargs.va + 2 * ia + 1);
  11939. + #ifdef DEBUG
  11940. +     if (ggdebug)
  11941. +         printf("inb 0x%x => 0x%x\n", ia, retval);
  11942. + #endif
  11943. +     return retval;
  11944. + }
  11945. + void
  11946. + ggbus_outw(ia, w)
  11947. +     int ia;
  11948. +     u_int16_t w;
  11949. + {
  11950. + #ifdef DEBUG
  11951. +     if (ggdebug)
  11952. +         printf("outw 0x%x,0x%x\n", ia, w);
  11953. + #endif
  11954. +     *(volatile u_int16_t *)(ggbusp->gd_zargs.va + 2 * ia) = swap (w);
  11955. + }
  11956. + u_int16_t
  11957. + ggbus_inw(ia)
  11958. +     int ia;
  11959. + {
  11960. +     u_int16_t retval =
  11961. +             swap(*(volatile u_int16_t *)(ggbusp->gd_zargs.va + 2 * ia));
  11962. + #ifdef DEBUG
  11963. +     if (ggdebug)
  11964. +         printf("inw 0x%x => 0x%x\n", ia, retval);
  11965. + #endif
  11966. +     return retval;
  11967. + }
  11968. *** /dev/null
  11969. --- NetBSD/src/sys/arch/amiga/isa/ggbusreg.h
  11970. ***************
  11971. *** 0 ****
  11972. --- 1,67 ----
  11973. + /*    $NetBSD: ggbusreg.h,v 1.1 1994/07/08 23:32:17 niklas Exp $    */
  11974. + /*
  11975. +  * Copyright (c) 1994 Niklas Hallqvist
  11976. +  * All rights reserved.
  11977. +  *
  11978. +  * Redistribution and use in source and binary forms, with or without
  11979. +  * modification, are permitted provided that the following conditions
  11980. +  * are met:
  11981. +  * 1. Redistributions of source code must retain the above copyright
  11982. +  *    notice, this list of conditions and the following disclaimer.
  11983. +  * 2. Redistributions in binary form must reproduce the above copyright
  11984. +  *    notice, this list of conditions and the following disclaimer in the
  11985. +  *    documentation and/or other materials provided with the distribution.
  11986. +  * 3. All advertising materials mentioning features or use of this software
  11987. +  *    must display the following acknowledgement:
  11988. +  *      This product includes software developed by Niklas Hallqvist.
  11989. +  * 4. The name of the author may not be used to endorse or promote products
  11990. +  *    derived from this software without specific prior written permission
  11991. +  *
  11992. +  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  11993. +  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  11994. +  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  11995. +  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  11996. +  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  11997. +  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  11998. +  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11999. +  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12000. +  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  12001. +  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12002. +  */
  12003. + #ifndef _GGBUSREG_H_
  12004. + #define _GGBUSREG_H_
  12005. + #define GG2_MEMORY_OFFSET (0x20000 - 2 * 0x90000)
  12006. + #define GG2_STATUS 0x18000
  12007. + #define GG2_GET_STATUS(va) (*(volatile u_short *)((va) + GG2_STATUS))
  12008. + #define GG2_MASTER 0
  12009. + #define GG2_WAIT 1
  12010. + #define GG2_IRQ3 2
  12011. + #define GG2_IRQ4 3
  12012. + #define GG2_IRQ5 4
  12013. + #define GG2_IRQ6 5
  12014. + #define GG2_IRQ7 6
  12015. + #define GG2_IRQ9 7
  12016. + #define GG2_IRQ10 8
  12017. + #define GG2_IRQ11 9
  12018. + #define GG2_IRQ12 10
  12019. + #define GG2_IRQ14 11
  12020. + #define GG2_IRQ15 12
  12021. + #define GG2_IRQ_MASK 0x1ffc
  12022. + #define GG2_GET_INT_STATUS(va) (GG2_GET_STATUS(va) & GG2_IRQ_MASK)
  12023. + #define GG2_INT_CTRL 0x18002
  12024. + #define GG2_DISABLE_INTS(va) (*(volatile u_short *)((va) + GG2_INT_CTRL))
  12025. + #define GG2_ENABLE_INTS(va) (*(volatile u_short *)((va) + GG2_INT_CTRL) = 0)
  12026. + #define GG2_WAIT_CTRL 0x18004
  12027. + #define GG2_TOGGLE_WAIT(va) (*(volatile u_char *)((va) + GG2_WAIT_CTRL))
  12028. + #define GG2_ENABLE_WAIT(va) \
  12029. +     while ((GG2_GET_STATUS(va) & 1 << GG2_WAIT) == 0) GG2_TOGGLE_WAIT(va)
  12030. + #define GG2_DISABLE_WAIT(va) \
  12031. +     while (GG2_GET_STATUS(va) & 1 << GG2_WAIT) GG2_TOGGLE_WAIT(va)
  12032. + #endif
  12033. *** /dev/null
  12034. --- NetBSD/src/sys/arch/amiga/isa/ggbusvar.h
  12035. ***************
  12036. *** 0 ****
  12037. --- 1,50 ----
  12038. + /*    $NetBSD: ggbusvar.h,v 1.1 1994/07/08 23:32:17 niklas Exp $    */
  12039. + /*
  12040. +  * Copyright (c) 1994, 1995 Niklas Hallqvist
  12041. +  * All rights reserved.
  12042. +  *
  12043. +  * Redistribution and use in source and binary forms, with or without
  12044. +  * modification, are permitted provided that the following conditions
  12045. +  * are met:
  12046. +  * 1. Redistributions of source code must retain the above copyright
  12047. +  *    notice, this list of conditions and the following disclaimer.
  12048. +  * 2. Redistributions in binary form must reproduce the above copyright
  12049. +  *    notice, this list of conditions and the following disclaimer in the
  12050. +  *    documentation and/or other materials provided with the distribution.
  12051. +  * 3. All advertising materials mentioning features or use of this software
  12052. +  *    must display the following acknowledgement:
  12053. +  *      This product includes software developed by Niklas Hallqvist.
  12054. +  * 4. The name of the author may not be used to endorse or promote products
  12055. +  *    derived from this software without specific prior written permission
  12056. +  *
  12057. +  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  12058. +  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  12059. +  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  12060. +  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  12061. +  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  12062. +  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  12063. +  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  12064. +  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12065. +  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  12066. +  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  12067. +  */
  12068. + #ifndef _GGBUSVAR_H_
  12069. + #define _GGBUSVAR_H_
  12070. + struct ggbus_device {
  12071. +     struct    device gd_dev;
  12072. +     struct    zbus_args gd_zargs;
  12073. +     struct    isa_link gd_link;
  12074. +     int    (*gd_ifunc[16])();
  12075. +     void    *gd_iarg[16];
  12076. +     int    gd_ipri[16];
  12077. +     int    gd_imask;
  12078. +     struct    isr gd_isr;
  12079. + };
  12080. + extern int ggdebug;
  12081. + #endif
  12082. *** /dev/null
  12083. --- NetBSD/src/sys/arch/amiga/isa/icu.h
  12084. ***************
  12085. *** 0 ****
  12086. --- 1,97 ----
  12087. + /*-
  12088. +  * Copyright (c) 1990 The Regents of the University of California.
  12089. +  * All rights reserved.
  12090. +  *
  12091. +  * This code is derived from software contributed to Berkeley by
  12092. +  * William Jolitz.
  12093. +  *
  12094. +  * Redistribution and use in source and binary forms, with or without
  12095. +  * modification, are permitted provided that the following conditions
  12096. +  * are met:
  12097. +  * 1. Redistributions of source code must retain the above copyright
  12098. +  *    notice, this list of conditions and the following disclaimer.
  12099. +  * 2. Redistributions in binary form must reproduce the above copyright
  12100. +  *    notice, this list of conditions and the following disclaimer in the
  12101. +  *    documentation and/or other materials provided with the distribution.
  12102. +  * 3. All advertising materials mentioning features or use of this software
  12103. +  *    must display the following acknowledgement:
  12104. +  *    This product includes software developed by the University of
  12105. +  *    California, Berkeley and its contributors.
  12106. +  * 4. Neither the name of the University nor the names of its contributors
  12107. +  *    may be used to endorse or promote products derived from this software
  12108. +  *    without specific prior written permission.
  12109. +  *
  12110. +  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  12111. +  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  12112. +  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  12113. +  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  12114. +  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  12115. +  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  12116. +  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  12117. +  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  12118. +  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  12119. +  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  12120. +  * SUCH DAMAGE.
  12121. +  *
  12122. +  *    from: @(#)icu.h    5.6 (Berkeley) 5/9/91
  12123. +  *    $Id$
  12124. +  */
  12125. + /*
  12126. +  * AT/386 Interrupt Control constants
  12127. +  * W. Jolitz 8/89
  12128. +  */
  12129. + #ifndef    __ICU__
  12130. + #define    __ICU__
  12131. + #ifndef    LOCORE
  12132. + /*
  12133. +  * Interrupt "level" mechanism variables, masks, and macros
  12134. +  */
  12135. + extern    unsigned imen;        /* interrupt mask enable */
  12136. + #define    INTREN(s)    do{imen &= ~(s); SET_ICUS();}while(0)
  12137. + #define    INTRDIS(s)    do{imen |= (s); SET_ICUS();}while(0)
  12138. + #define    INTRMASK(msk,s)    (msk |= (s))
  12139. + #if 0
  12140. + #define SET_ICUS()    do{outb(IO_ICU1 + 1, imen); outb(IU_ICU2 + 1, imen >> 8);}while(0)
  12141. + #else
  12142. + /*
  12143. +  * XXX - IO_ICU* are defined in isa.h, not icu.h, and nothing much bothers to
  12144. +  * include isa.h, while too many things include icu.h.
  12145. +  */
  12146. + #define SET_ICUS()    do{outb(0x21, imen); outb(0xa1, imen >> 8);}while(0)
  12147. + #endif
  12148. + #endif
  12149. + /*
  12150. +  * Interrupt enable bits -- in order of priority
  12151. +  */
  12152. + #define    IRQ0        0x0001        /* highest priority - timer */
  12153. + #define    IRQ1        0x0002
  12154. + #define    IRQ_SLAVE    0x0004
  12155. + #define    IRQ8        0x0100
  12156. + #define    IRQ9        0x0200
  12157. + #define    IRQ2        IRQ9
  12158. + #define    IRQ10        0x0400
  12159. + #define    IRQ11        0x0800
  12160. + #define    IRQ12        0x1000
  12161. + #define    IRQ13        0x2000
  12162. + #define    IRQ14        0x4000
  12163. + #define    IRQ15        0x8000
  12164. + #define    IRQ3        0x0008
  12165. + #define    IRQ4        0x0010
  12166. + #define    IRQ5        0x0020
  12167. + #define    IRQ6        0x0040
  12168. + #define    IRQ7        0x0080        /* lowest - parallel printer */
  12169. + /*
  12170. +  * Interrupt Control offset into Interrupt descriptor table (IDT)
  12171. +  */
  12172. + #define    ICU_OFFSET    32        /* 0-31 are processor exceptions */
  12173. + #define    ICU_LEN        16        /* 32-47 are ISA interrupts */
  12174. + #endif    __ICU__
  12175. *** /dev/null
  12176. --- NetBSD/src/sys/arch/amiga/isa/if_isaed.c
  12177. ***************
  12178. *** 0 ****
  12179. --- 1,2321 ----
  12180. + /*    $NetBSD: if_isaed.c,v 1.7 1994/11/28 21:47:38 root Exp $    */
  12181. + /*
  12182. +  * Copyright (c) 1994, 1995 Niklas Hallqvist.
  12183. +  * All rights reserved.
  12184. +  *
  12185. +  * Amiga adaptation based on:
  12186. +  *
  12187. +  * Device driver for National Semiconductor DS8390/WD83C690 based ethernet
  12188. +  * adapters.
  12189. +  *
  12190. +  * Copyright (c) 1994, 1995 Charles Hannum.
  12191. +  * All rights reserved.
  12192. +  *
  12193. +  * Copyright (C) 1993, David Greenman.  This software may be used, modified,
  12194. +  * copied, distributed, and sold, in both source and binary form provided that
  12195. +  * the above copyright and these terms are retained.  Under no circumstances is
  12196. +  * the author responsible for the proper functioning of this software, nor does
  12197. +  * the author assume any responsibility for damages incurred with its use.
  12198. +  *
  12199. +  * Currently supports the Western Digital/SMC 8003 and 8013 series, the SMC
  12200. +  * Elite Ultra (8216), the 3Com 3c503, the NE1000 and NE2000, and a variety of
  12201. +  * similar clones.
  12202. +  */
  12203. + #include "bpfilter.h"
  12204. + #include <sys/param.h>
  12205. + #include <sys/systm.h>
  12206. + #include <sys/errno.h>
  12207. + #include <sys/ioctl.h>
  12208. + #include <sys/mbuf.h>
  12209. + #include <sys/socket.h>
  12210. + #include <sys/syslog.h>
  12211. + #include <sys/device.h>
  12212. + #include <net/if.h>
  12213. + #include <net/if_dl.h>
  12214. + #include <net/if_types.h>
  12215. + #include <net/netisr.h>
  12216. + #ifdef INET
  12217. + #include <netinet/in.h>
  12218. + #include <netinet/in_systm.h>
  12219. + #include <netinet/in_var.h>
  12220. + #include <netinet/ip.h>
  12221. + #include <netinet/if_ether.h>
  12222. + #endif
  12223. + #ifdef NS
  12224. + #include <netns/ns.h>
  12225. + #include <netns/ns_if.h>
  12226. + #endif
  12227. + #if NBPFILTER > 0
  12228. + #include <net/bpf.h>
  12229. + #include <net/bpfdesc.h>
  12230. + #endif
  12231. + #include <machine/cpu.h>
  12232. + #include <machine/pio.h>
  12233. + #include <dev/isa/isareg.h>
  12234. + #include <dev/isa/isavar.h>
  12235. + #include <dev/isa/if_edreg.h>
  12236. + #define ED_BYTE_ORDER LITTLE_ENDIAN
  12237. + #include <dev/ic/dp8390reg.h>
  12238. + #include <amiga/isa/isa_machdep.h>    /* XXX USES ISA HOLE DIRECTLY */
  12239. + /*
  12240. +  * isaed_softc: per line info and status
  12241. +  */
  12242. + struct isaed_softc {
  12243. +     struct    device sc_dev;
  12244. +     void *sc_ih;
  12245. +     struct    arpcom sc_arpcom;    /* ethernet common */
  12246. +     char    *type_str;    /* pointer to type string */
  12247. +     u_char    vendor;        /* interface vendor */
  12248. +     u_char    type;        /* interface type code */
  12249. +     int    asic_addr;    /* ASIC I/O bus address */
  12250. +     int    nic_addr;    /* NIC (DS8390) I/O bus address */
  12251. + /*
  12252. +  * The following 'proto' variable is part of a work-around for 8013EBT asics
  12253. +  * being write-only.  It's sort of a prototype/shadow of the real thing.
  12254. +  */
  12255. +     u_char    wd_laar_proto;
  12256. + /*
  12257. +  * This `proto' variable is so we can turn MENB on and off without reading
  12258. +  * the value back from the card all the time.
  12259. +  */
  12260. +     u_char    wd_msr_proto;
  12261. +     u_char    cr_proto;    /* values always set in CR */
  12262. +     u_char    isa16bit;    /* width of access to card 0=8 or 1=16 */
  12263. +     u_char    is790;        /* set by probe if NIC is a 790 */
  12264. +     caddr_t    mem_start;    /* NIC memory start address */
  12265. +     caddr_t    mem_end;    /* NIC memory end address */
  12266. +     u_long    mem_size;    /* total NIC memory size */
  12267. +     caddr_t    mem_ring;    /* start of RX ring-buffer (in NIC mem) */
  12268. +     u_char    mem_shared;    /* NIC memory is shared with host */
  12269. +     u_char    txb_cnt;    /* number of transmit buffers */
  12270. +     u_char    txb_inuse;    /* number of transmit buffers active */
  12271. +     u_char     txb_new;    /* pointer to where new buffer will be added */
  12272. +     u_char    txb_next_tx;    /* pointer to next buffer ready to xmit */
  12273. +     u_short    txb_len[8];    /* buffered xmit buffer lengths */
  12274. +     u_char    tx_page_start;    /* first page of TX buffer area */
  12275. +     u_char    rec_page_start;    /* first page of RX ring-buffer */
  12276. +     u_char    rec_page_stop;    /* last page of RX ring-buffer */
  12277. +     u_char    next_packet;    /* pointer to next unread RX packet */
  12278. + };
  12279. + int isaedprobe __P((struct device *, void *, void *));
  12280. + void isaedattach __P((struct device *, struct device *, void *));
  12281. + int isaedintr __P((void *));
  12282. + int isaedioctl __P((struct ifnet *, u_long, caddr_t));
  12283. + void isaedstart __P((struct ifnet *));
  12284. + void isaedwatchdog __P((int));
  12285. + void isaedreset __P((struct isaed_softc *));
  12286. + void isaedinit __P((struct isaed_softc *));
  12287. + void isaedstop __P((struct isaed_softc *));
  12288. + #define inline    /* XXX for debugging porpoises */
  12289. + void isaed_getmcaf __P((struct arpcom *, u_long *));
  12290. + void isaedread __P((struct isaed_softc *, caddr_t, int));
  12291. + struct mbuf *isaedget __P((struct isaed_softc *, caddr_t, int));
  12292. + static inline void isaed_rint __P((struct isaed_softc *));
  12293. + static inline void isaed_xmit __P((struct isaed_softc *));
  12294. + static inline caddr_t isaed_ring_copy __P((struct isaed_softc *, caddr_t,
  12295. +                        caddr_t, u_short));
  12296. + void isaed_pio_readmem __P((struct isaed_softc *, u_short, caddr_t, u_short));
  12297. + void isaed_pio_writemem __P((struct isaed_softc *, caddr_t, u_short, u_short));
  12298. + u_short isaed_pio_write_mbufs __P((struct isaed_softc *, struct mbuf *, u_short));
  12299. + #ifdef ISAED_DEBUG
  12300. + int isaeddebug = 0;
  12301. + #endif
  12302. + int isaedprobes = 7;
  12303. + struct cfdriver isaedcd = {
  12304. +     NULL, "isaed", isaedprobe, isaedattach, DV_IFNET, sizeof(struct isaed_softc)
  12305. + };
  12306. + #define    ETHER_MIN_LEN    64
  12307. + #define ETHER_MAX_LEN    1518
  12308. + #define    ETHER_ADDR_LEN    6
  12309. + #define    NIC_PUT(sc, off, val)    outb(sc->nic_addr + off, val)
  12310. + #define    NIC_GET(sc, off)    inb(sc->nic_addr + off)
  12311. + /*
  12312. +  * Determine if the device is present.
  12313. +  */
  12314. + int
  12315. + isaedprobe(parent, match, aux)
  12316. +     struct device *parent;
  12317. +     void *match, *aux;
  12318. + {
  12319. +     struct isaed_softc *sc = match;
  12320. +     struct cfdata *cf = sc->sc_dev.dv_cfdata;
  12321. +     struct isa_attach_args *ia = aux;
  12322. +     if ((isaedprobes & 1) && isaed_probe_WD80x3(sc, cf, ia))
  12323. +         return (1);
  12324. +     if ((isaedprobes & 2) && isaed_probe_3Com(sc, cf, ia))
  12325. +         return (1);
  12326. +     if ((isaedprobes & 4) && isaed_probe_Novell(sc, cf, ia))
  12327. +         return (1);
  12328. +     return (0);
  12329. + }
  12330. + /*
  12331. +  * Generic probe routine for testing for the existance of a DS8390.  Must be
  12332. +  * called after the NIC has just been reset.  This routine works by looking at
  12333. +  * certain register values that are guaranteed to be initialized a certain way
  12334. +  * after power-up or reset.  Seems not to currently work on the 83C690.
  12335. +  *
  12336. +  * Specifically:
  12337. +  *
  12338. +  *    Register            reset bits    set bits
  12339. +  *    Command Register (CR)        TXP, STA    RD2, STP
  12340. +  *    Interrupt Status (ISR)                RST
  12341. +  *    Interrupt Mask (IMR)        All bits
  12342. +  *    Data Control (DCR)                LAS
  12343. +  *    Transmit Config. (TCR)        LB1, LB0
  12344. +  *
  12345. +  * We only look at the CR and ISR registers, however, because looking at the
  12346. +  * others would require changing register pages (which would be intrusive if
  12347. +  * this isn't an 8390).
  12348. +  *
  12349. +  * Return 1 if 8390 was found, 0 if not.
  12350. +  */
  12351. + int
  12352. + isaed_probe_generic8390(sc)
  12353. +     struct isaed_softc *sc;
  12354. + {
  12355. +     if ((NIC_GET(sc, ED_P0_CR) &
  12356. +          (ED_CR_RD2 | ED_CR_TXP | ED_CR_STA | ED_CR_STP)) !=
  12357. +         (ED_CR_RD2 | ED_CR_STP))
  12358. +         return (0);
  12359. +     if ((NIC_GET(sc, ED_P0_ISR) & ED_ISR_RST) != ED_ISR_RST)
  12360. +         return (0);
  12361. +     return (1);
  12362. + }
  12363. + int isaed_wd584_irq[] = { 9, 3, 5, 7, 10, 11, 15, 4 };
  12364. + int isaed_wd790_irq[] = { IRQUNK, 9, 3, 5, 7, 10, 11, 15 };
  12365. + /*
  12366. +  * Probe and vendor-specific initialization routine for SMC/WD80x3 boards.
  12367. +  */
  12368. + int
  12369. + isaed_probe_WD80x3(sc, cf, ia)
  12370. +     struct isaed_softc *sc;
  12371. +     struct cfdata *cf;
  12372. +     struct isa_attach_args *ia;
  12373. + {
  12374. +     int i;
  12375. +     u_int memsize;
  12376. +     u_char iptr, isa16bit, sum;
  12377. +     sc->asic_addr = ia->ia_iobase;
  12378. +     sc->nic_addr = sc->asic_addr + ED_WD_NIC_OFFSET;
  12379. +     sc->is790 = 0;
  12380. + #ifdef TOSH_ETHER
  12381. +     outb(sc->asic_addr + ED_WD_MSR, ED_WD_MSR_POW);
  12382. +     delay(10000);
  12383. + #endif
  12384. +     /*
  12385. +      * Attempt to do a checksum over the station address PROM.  If it
  12386. +      * fails, it's probably not a SMC/WD board.  There is a problem with
  12387. +      * this, though: some clone WD boards don't pass the checksum test.
  12388. +      * Danpex boards for one.
  12389. +      */
  12390. +     for (sum = 0, i = 0; i < 8; ++i) {
  12391. +         u_char c = inb(sc->asic_addr + ED_WD_PROM + i);
  12392. +         sum += c;
  12393. + #ifdef ISAED_DEBUG
  12394. +         if (isaeddebug)
  12395. +             printf("inb(0x%x) = 0x%02x -> sum = %d\n",
  12396. +                 sc->asic_addr + ED_WD_PROM + i, c, sum);
  12397. + #endif
  12398. +     }
  12399. +     if (sum != ED_WD_ROM_CHECKSUM_TOTAL) {
  12400. +         /*
  12401. +          * Checksum is invalid.  This often happens with cheap WD8003E
  12402. +          * clones.  In this case, the checksum byte (the eighth byte)
  12403. +          * seems to always be zero.
  12404. +          */
  12405. +         if (inb(sc->asic_addr + ED_WD_CARD_ID) != ED_TYPE_WD8003E ||
  12406. +             inb(sc->asic_addr + ED_WD_PROM + 7) != 0)
  12407. +             return (0);
  12408. +     }
  12409. +     /* Reset card to force it into a known state. */
  12410. + #ifdef TOSH_ETHER
  12411. +     outb(sc->asic_addr + ED_WD_MSR, ED_WD_MSR_RST | ED_WD_MSR_POW);
  12412. + #else
  12413. +     outb(sc->asic_addr + ED_WD_MSR, ED_WD_MSR_RST);
  12414. + #endif
  12415. +     delay(100);
  12416. +     outb(sc->asic_addr + ED_WD_MSR,
  12417. +         inb(sc->asic_addr + ED_WD_MSR) & ~ED_WD_MSR_RST);
  12418. +     /* Wait in the case this card is reading it's EEROM. */
  12419. +     delay(5000);
  12420. +     sc->vendor = ED_VENDOR_WD_SMC;
  12421. +     sc->type = inb(sc->asic_addr + ED_WD_CARD_ID);
  12422. +     /* Set initial values for width/size. */
  12423. +     memsize = 8192;
  12424. +     isa16bit = 0;
  12425. +     switch (sc->type) {
  12426. +     case ED_TYPE_WD8003S:
  12427. +         sc->type_str = "WD8003S";
  12428. +         break;
  12429. +     case ED_TYPE_WD8003E:
  12430. +         sc->type_str = "WD8003E";
  12431. +         break;
  12432. +     case ED_TYPE_WD8003EB:
  12433. +         sc->type_str = "WD8003EB";
  12434. +         break;
  12435. +     case ED_TYPE_WD8003W:
  12436. +         sc->type_str = "WD8003W";
  12437. +         break;
  12438. +     case ED_TYPE_WD8013EBT:
  12439. +         sc->type_str = "WD8013EBT";
  12440. +         memsize = 16384;
  12441. +         isa16bit = 1;
  12442. +         break;
  12443. +     case ED_TYPE_WD8013W:
  12444. +         sc->type_str = "WD8013W";
  12445. +         memsize = 16384;
  12446. +         isa16bit = 1;
  12447. +         break;
  12448. +     case ED_TYPE_WD8013EP:        /* also WD8003EP */
  12449. +         if (inb(sc->asic_addr + ED_WD_ICR) & ED_WD_ICR_16BIT) {
  12450. +             isa16bit = 1;
  12451. +             memsize = 16384;
  12452. +             sc->type_str = "WD8013EP";
  12453. +         } else
  12454. +             sc->type_str = "WD8003EP";
  12455. +         break;
  12456. +     case ED_TYPE_WD8013WC:
  12457. +         sc->type_str = "WD8013WC";
  12458. +         memsize = 16384;
  12459. +         isa16bit = 1;
  12460. +         break;
  12461. +     case ED_TYPE_WD8013EBP:
  12462. +         sc->type_str = "WD8013EBP";
  12463. +         memsize = 16384;
  12464. +         isa16bit = 1;
  12465. +         break;
  12466. +     case ED_TYPE_WD8013EPC:
  12467. +         sc->type_str = "WD8013EPC";
  12468. +         memsize = 16384;
  12469. +         isa16bit = 1;
  12470. +         break;
  12471. +     case ED_TYPE_SMC8216C:
  12472. +         sc->type_str = "SMC8216/SMC8216C";
  12473. +         memsize = 16384;
  12474. +         isa16bit = 1;
  12475. +         sc->is790 = 1;
  12476. +         break;
  12477. +     case ED_TYPE_SMC8216T:
  12478. +         sc->type_str = "SMC8216T";
  12479. +         memsize = 16384;
  12480. +         isa16bit = 1;
  12481. +         sc->is790 = 1;
  12482. +         break;
  12483. + #ifdef TOSH_ETHER
  12484. +     case ED_TYPE_TOSHIBA1:
  12485. +         sc->type_str = "Toshiba1";
  12486. +         memsize = 32768;
  12487. +         isa16bit = 1;
  12488. +         break;
  12489. +     case ED_TYPE_TOSHIBA4:
  12490. +         sc->type_str = "Toshiba4";
  12491. +         memsize = 32768;
  12492. +         isa16bit = 1;
  12493. +         break;
  12494. + #endif
  12495. +     default:
  12496. +         sc->type_str = NULL;
  12497. +         break;
  12498. +     }
  12499. +     /*
  12500. +      * Make some adjustments to initial values depending on what is found
  12501. +      * in the ICR.
  12502. +      */
  12503. +     if (isa16bit && (sc->type != ED_TYPE_WD8013EBT) &&
  12504. + #ifdef TOSH_ETHER
  12505. +         (sc->type != ED_TYPE_TOSHIBA1) && (sc->type != ED_TYPE_TOSHIBA4) &&
  12506. + #endif
  12507. +         ((inb(sc->asic_addr + ED_WD_ICR) & ED_WD_ICR_16BIT) == 0)) {
  12508. +         isa16bit = 0;
  12509. +         memsize = 8192;
  12510. +     }
  12511. + #ifdef ISAED_DEBUG
  12512. +     if (isaeddebug) {
  12513. +         printf("type=%x type_str=%s isa16bit=%d memsize=%d ia_msize=%d\n",
  12514. +             sc->type, sc->type_str ?: "unknown", isa16bit, memsize,
  12515. +             ia->ia_msize);
  12516. +         for (i = 0; i < 8; i++)
  12517. +             printf("%x -> %x\n", i, inb(sc->asic_addr + i));
  12518. +     }
  12519. + #endif
  12520. +     /* Allow the user to override the autoconfiguration. */
  12521. +     if (ia->ia_msize)
  12522. +         memsize = ia->ia_msize;
  12523. +     /*
  12524. +      * (Note that if the user specifies both of the following flags that
  12525. +      * '8-bit' mode intentionally has precedence.)
  12526. +      */
  12527. +     if (cf->cf_flags & ED_FLAGS_FORCE_16BIT_MODE)
  12528. +         isa16bit = 1;
  12529. +     if (cf->cf_flags & ED_FLAGS_FORCE_8BIT_MODE)
  12530. +         isa16bit = 0;
  12531. +     /*
  12532. +      * If possible, get the assigned interrupt number from the card and
  12533. +      * use it.
  12534. +      */
  12535. +     if (sc->is790) {
  12536. +         u_char x;
  12537. +         /* Assemble together the encoded interrupt number. */
  12538. +         outb(ia->ia_iobase + ED_WD790_HWR,
  12539. +             inb(ia->ia_iobase + ED_WD790_HWR) | ED_WD790_HWR_SWH);
  12540. +         x = inb(ia->ia_iobase + ED_WD790_GCR);
  12541. +         iptr = ((x & ED_WD790_GCR_IR2) >> 4) |
  12542. +             ((x & (ED_WD790_GCR_IR1|ED_WD790_GCR_IR0)) >> 2);
  12543. +         outb(ia->ia_iobase + ED_WD790_HWR,
  12544. +             inb(ia->ia_iobase + ED_WD790_HWR) & ~ED_WD790_HWR_SWH);
  12545. +         /*
  12546. +          * Translate it using translation table, and check for
  12547. +          * correctness.
  12548. +          */
  12549. +         if (ia->ia_irq != IRQUNK) {
  12550. +             if (ia->ia_irq != isaed_wd790_irq[iptr]) {
  12551. +                 printf("%s: irq mismatch; kernel configured %d != board configured %d\n",
  12552. +                     sc->sc_dev.dv_xname, ia->ia_irq,
  12553. +                     isaed_wd790_irq[iptr]);
  12554. +                 return (0);
  12555. +             }
  12556. +         } else
  12557. +             ia->ia_irq = isaed_wd790_irq[iptr];
  12558. +         /* Enable the interrupt. */
  12559. +         outb(ia->ia_iobase + ED_WD790_ICR,
  12560. +             inb(ia->ia_iobase + ED_WD790_ICR) | ED_WD790_ICR_EIL);
  12561. +     } else if (sc->type & ED_WD_SOFTCONFIG) {
  12562. +         /* Assemble together the encoded interrupt number. */
  12563. +         iptr = (inb(ia->ia_iobase + ED_WD_ICR) & ED_WD_ICR_IR2) |
  12564. +             ((inb(ia->ia_iobase + ED_WD_IRR) &
  12565. +               (ED_WD_IRR_IR0 | ED_WD_IRR_IR1)) >> 5);
  12566. +         /*
  12567. +          * Translate it using translation table, and check for
  12568. +          * correctness.
  12569. +          */
  12570. +         if (ia->ia_irq != IRQUNK) {
  12571. +             if (ia->ia_irq != isaed_wd584_irq[iptr]) {
  12572. +                 printf("%s: irq mismatch; kernel configured %d != board configured %d\n",
  12573. +                     sc->sc_dev.dv_xname, ia->ia_irq,
  12574. +                     isaed_wd584_irq[iptr]);
  12575. +                 return (0);
  12576. +             }
  12577. +         } else
  12578. +             ia->ia_irq = isaed_wd584_irq[iptr];
  12579. +         /* Enable the interrupt. */
  12580. +         outb(ia->ia_iobase + ED_WD_IRR,
  12581. +             inb(ia->ia_iobase + ED_WD_IRR) | ED_WD_IRR_IEN);
  12582. +     } else {
  12583. +         if (ia->ia_irq == IRQUNK) {
  12584. +             printf("%s: %s does not have soft configuration\n",
  12585. +                 sc->sc_dev.dv_xname, sc->type_str);
  12586. +             return (0);
  12587. +         }
  12588. +     }
  12589. +     /* XXX Figure out the shared memory address. */
  12590. +     sc->isa16bit = isa16bit;
  12591. +     sc->mem_shared = 1;
  12592. +     ia->ia_msize = memsize;
  12593. +     sc->mem_start = ISA_HOLE_VADDR(ia->ia_maddr);
  12594. +     /* Allocate one xmit buffer if < 16k, two buffers otherwise. */
  12595. +     if ((memsize < 16384) || (cf->cf_flags & ED_FLAGS_NO_MULTI_BUFFERING))
  12596. +         sc->txb_cnt = 1;
  12597. +     else
  12598. +         sc->txb_cnt = 2;
  12599. +     sc->tx_page_start = ED_WD_PAGE_OFFSET;
  12600. +     sc->rec_page_start = sc->tx_page_start + sc->txb_cnt * ED_TXBUF_SIZE;
  12601. +     sc->rec_page_stop = sc->tx_page_start + (memsize >> ED_PAGE_SHIFT);
  12602. +     sc->mem_ring = sc->mem_start + (sc->rec_page_start << ED_PAGE_SHIFT);
  12603. +     sc->mem_size = memsize;
  12604. +     sc->mem_end = sc->mem_start + memsize;
  12605. +     /* Get station address from on-board ROM. */
  12606. +     for (i = 0; i < ETHER_ADDR_LEN; ++i)
  12607. +         sc->sc_arpcom.ac_enaddr[i] =
  12608. +             inb(sc->asic_addr + ED_WD_PROM + i);
  12609. +     /*
  12610. +      * Set upper address bits and 8/16 bit access to shared memory.
  12611. +      */
  12612. +     if (isa16bit) {
  12613. +         if (sc->is790) {
  12614. +             sc->wd_laar_proto =
  12615. +                 inb(sc->asic_addr + ED_WD_LAAR) &
  12616. +                 ~ED_WD_LAAR_M16EN;
  12617. +         } else {
  12618. +             sc->wd_laar_proto =
  12619. +                 ED_WD_LAAR_L16EN |
  12620. +                 ((kvtop(sc->mem_start) >> 19) &
  12621. +                 ED_WD_LAAR_ADDRHI);
  12622. +         }
  12623. +         outb(sc->asic_addr + ED_WD_LAAR,
  12624. +             sc->wd_laar_proto | ED_WD_LAAR_M16EN);
  12625. +     } else  {
  12626. +         if ((sc->type & ED_WD_SOFTCONFIG) ||
  12627. + #ifdef TOSH_ETHER
  12628. +             (sc->type == ED_TYPE_TOSHIBA1) ||
  12629. +             (sc->type == ED_TYPE_TOSHIBA4) ||
  12630. + #endif
  12631. +             (sc->type == ED_TYPE_WD8013EBT) && !sc->is790) {
  12632. +             sc->wd_laar_proto =
  12633. +                 ((kvtop(sc->mem_start) >> 19) &
  12634. +                 ED_WD_LAAR_ADDRHI);
  12635. +             outb(sc->asic_addr + ED_WD_LAAR,
  12636. +                 sc->wd_laar_proto);
  12637. +         }
  12638. +     }
  12639. +     /*
  12640. +      * Set address and enable interface shared memory.
  12641. +      */
  12642. +     if (!sc->is790) {
  12643. + #ifdef TOSH_ETHER
  12644. +         outb(sc->asic_addr + ED_WD_MSR + 1,
  12645. +             ((kvtop(sc->mem_start) >> 8) & 0xe0) | 4);
  12646. +         outb(sc->asic_addr + ED_WD_MSR + 2,
  12647. +             ((kvtop(sc->mem_start) >> 16) & 0x0f));
  12648. +         sc->wd_msr_proto = ED_WD_MSR_POW;
  12649. + #else
  12650. +         sc->wd_msr_proto =
  12651. +             (kvtop(sc->mem_start) >> 13) & ED_WD_MSR_ADDR;
  12652. + #endif
  12653. +         sc->cr_proto = ED_CR_RD2;
  12654. +     } else {
  12655. +         outb(sc->asic_addr + 0x04,
  12656. +             inb(sc->asic_addr + 0x04) | 0x80);
  12657. +         outb(sc->asic_addr + 0x0b,
  12658. +             ((kvtop(sc->mem_start) >> 13) & 0x0f) |
  12659. +             ((kvtop(sc->mem_start) >> 11) & 0x40) |
  12660. +             (inb(sc->asic_addr + 0x0b) & 0xb0));
  12661. +         outb(sc->asic_addr + 0x04,
  12662. +             inb(sc->asic_addr + 0x04) & ~0x80);
  12663. +         sc->wd_msr_proto = 0x00;
  12664. +         sc->cr_proto = 0;
  12665. +     }
  12666. +     outb(sc->asic_addr + ED_WD_MSR,
  12667. +         sc->wd_msr_proto | ED_WD_MSR_MENB);
  12668. +     (void) inb(0x84);
  12669. +     (void) inb(0x84);
  12670. +     /* Now zero memory and verify that it is clear. */
  12671. +     bzero(sc->mem_start, memsize);
  12672. +     for (i = 0; i < memsize; ++i)
  12673. +         if (sc->mem_start[i]) {
  12674. +             printf("%s: failed to clear shared memory at %x - check configuration\n",
  12675. +                 sc->sc_dev.dv_xname,
  12676. +                 kvtop(sc->mem_start + i));
  12677. +             /* Disable 16 bit access to shared memory. */
  12678. +             outb(sc->asic_addr + ED_WD_MSR,
  12679. +                 sc->wd_msr_proto);
  12680. +             if (isa16bit)
  12681. +                 outb(sc->asic_addr + ED_WD_LAAR,
  12682. +                     sc->wd_laar_proto);
  12683. +             (void) inb(0x84);
  12684. +             (void) inb(0x84);
  12685. +             return (0);
  12686. +         }
  12687. +     /*
  12688. +      * Disable 16bit access to shared memory - we leave it disabled
  12689. +      * so that 1) machines reboot properly when the board is set 16
  12690. +      * 16 bit mode and there are conflicting 8bit devices/ROMS in
  12691. +      * the same 128k address space as this boards shared memory,
  12692. +      * and 2) so that other 8 bit devices with shared memory can be
  12693. +      * used in this 128k region, too.
  12694. +      */
  12695. +     outb(sc->asic_addr + ED_WD_MSR, sc->wd_msr_proto);
  12696. +     if (isa16bit)
  12697. +         outb(sc->asic_addr + ED_WD_LAAR, sc->wd_laar_proto);
  12698. +     (void) inb(0x84);
  12699. +     (void) inb(0x84);
  12700. +     ia->ia_iosize = ED_WD_IO_PORTS;
  12701. +     return (1);
  12702. + }
  12703. + int isaed_3com_iobase[] = {0x2e0, 0x2a0, 0x280, 0x250, 0x350, 0x330, 0x310, 0x300};
  12704. + int isaed_3com_maddr[] = {MADDRUNK, MADDRUNK, MADDRUNK, MADDRUNK, 0xc8000, 0xcc000, 0xd8000, 0xdc000};
  12705. + #if 0
  12706. + int isaed_3com_irq[] = {IRQUNK, IRQUNK, IRQUNK, IRQUNK, 9, 3, 4, 5};
  12707. + #endif
  12708. + /*
  12709. +  * Probe and vendor-specific initialization routine for 3Com 3c503 boards.
  12710. +  */
  12711. + int
  12712. + isaed_probe_3Com(sc, cf, ia)
  12713. +     struct isaed_softc *sc;
  12714. +     struct cfdata *cf;
  12715. +     struct isa_attach_args *ia;
  12716. + {
  12717. +     int i;
  12718. +     u_int memsize;
  12719. +     u_char isa16bit, sum, x;
  12720. +     int ptr;
  12721. +     sc->asic_addr = ia->ia_iobase + ED_3COM_ASIC_OFFSET;
  12722. +     sc->nic_addr = ia->ia_iobase + ED_3COM_NIC_OFFSET;
  12723. +     /*
  12724. +      * Verify that the kernel configured I/O address matches the board
  12725. +      * configured address.
  12726. +      *
  12727. +      * This is really only useful to see if something that looks like the
  12728. +      * board is there; after all, we are already talking it at that
  12729. +      * address.
  12730. +      */
  12731. +     x = inb(sc->asic_addr + ED_3COM_BCFR);
  12732. +     if (x == 0 || (x & (x - 1)) != 0)
  12733. +         return (0);
  12734. +     ptr = ffs(x) - 1;
  12735. +     if (ia->ia_iobase != IOBASEUNK) {
  12736. +         if (ia->ia_iobase != isaed_3com_iobase[ptr]) {
  12737. +             printf("%s: %s mismatch; kernel configured %x != board configured %x\n",
  12738. +                 "iobase", sc->sc_dev.dv_xname, ia->ia_iobase,
  12739. +                 isaed_3com_iobase[ptr]);
  12740. +             return (0);
  12741. +         }
  12742. +     } else
  12743. +         ia->ia_iobase = isaed_3com_iobase[ptr];
  12744. +     x = inb(sc->asic_addr + ED_3COM_PCFR);
  12745. +     if (x == 0 || (x & (x - 1)) != 0)
  12746. +         return (0);
  12747. +     ptr = ffs(x) - 1;
  12748. +     if (ia->ia_maddr != MADDRUNK) {
  12749. +         if (ia->ia_maddr != isaed_3com_maddr[ptr]) {
  12750. +             printf("%s: %s mismatch; kernel configured %x != board configured %x\n",
  12751. +                 "maddr", sc->sc_dev.dv_xname, ia->ia_maddr,
  12752. +                 isaed_3com_maddr[ptr]);
  12753. +             return (0);
  12754. +         }
  12755. +     } else
  12756. +         ia->ia_maddr = isaed_3com_maddr[ptr];
  12757. + #if 0
  12758. +     x = inb(sc->asic_addr + ED_3COM_IDCFR) & ED_3COM_IDCFR_IRQ;
  12759. +     if (x == 0 || (x & (x - 1)) != 0)
  12760. +         return (0);
  12761. +     ptr = ffs(x) - 1;
  12762. +     if (ia->ia_irq != IRQUNK) {
  12763. +         if (ia->ia_irq != isaed_3com_irq[ptr]) {
  12764. +             printf("%s: irq mismatch; kernel configured %d != board configured %d\n",
  12765. +                 sc->sc_dev.dv_xname, ia->ia_irq,
  12766. +                 isaed_3com_irq[ptr]);
  12767. +             return (0);
  12768. +         }
  12769. +     } else
  12770. +         ia->ia_irq = isaed_3com_irq[ptr];
  12771. + #endif
  12772. +     /*
  12773. +      * Reset NIC and ASIC.  Enable on-board transceiver throughout reset
  12774. +      * sequence because it'll lock up if the cable isn't connected if we
  12775. +      * don't.
  12776. +      */
  12777. +     outb(sc->asic_addr + ED_3COM_CR, ED_3COM_CR_RST | ED_3COM_CR_XSEL);
  12778. +     /* Wait for a while, then un-reset it. */
  12779. +     delay(50);
  12780. +     /*
  12781. +      * The 3Com ASIC defaults to rather strange settings for the CR after a
  12782. +      * reset - it's important to set it again after the following outb
  12783. +      * (this is done when we map the PROM below).
  12784. +      */
  12785. +     outb(sc->asic_addr + ED_3COM_CR, ED_3COM_CR_XSEL);
  12786. +     /* Wait a bit for the NIC to recover from the reset. */
  12787. +     delay(5000);
  12788. +     sc->vendor = ED_VENDOR_3COM;
  12789. +     sc->type_str = "3c503";
  12790. +     sc->mem_shared = 1;
  12791. +     sc->cr_proto = ED_CR_RD2;
  12792. +     /*
  12793. +      * Hmmm...a 16bit 3Com board has 16k of memory, but only an 8k window
  12794. +      * to it.
  12795. +      */
  12796. +     memsize = 8192;
  12797. +     /*
  12798. +      * Get station address from on-board ROM.
  12799. +      *
  12800. +      * First, map ethernet address PROM over the top of where the NIC
  12801. +      * registers normally appear.
  12802. +      */
  12803. +     outb(sc->asic_addr + ED_3COM_CR, ED_3COM_CR_EALO | ED_3COM_CR_XSEL);
  12804. +     for (i = 0; i < ETHER_ADDR_LEN; ++i)
  12805. +         sc->sc_arpcom.ac_enaddr[i] = NIC_GET(sc, i);
  12806. +     /*
  12807. +      * Unmap PROM - select NIC registers.  The proper setting of the
  12808. +      * tranceiver is set in isaedinit so that the attach code is given a
  12809. +      * chance to set the default based on a compile-time config option.
  12810. +      */
  12811. +     outb(sc->asic_addr + ED_3COM_CR, ED_3COM_CR_XSEL);
  12812. +     /* Determine if this is an 8bit or 16bit board. */
  12813. +     /* Select page 0 registers. */
  12814. +     NIC_PUT(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STP);
  12815. +     /*
  12816. +      * Attempt to clear WTS bit.  If it doesn't clear, then this is a
  12817. +      * 16-bit board.
  12818. +      */
  12819. +     NIC_PUT(sc, ED_P0_DCR, 0);
  12820. +     /* Select page 2 registers. */
  12821. +     NIC_PUT(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_2 | ED_CR_STP);
  12822. +     /* The 3c503 forces the WTS bit to a one if this is a 16bit board. */
  12823. +     if (NIC_GET(sc, ED_P2_DCR) & ED_DCR_WTS)
  12824. +         isa16bit = 1;
  12825. +     else
  12826. +         isa16bit = 0;
  12827. +     /* Select page 0 registers. */
  12828. +     NIC_PUT(sc, ED_P2_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STP);
  12829. +     sc->mem_start = ISA_HOLE_VADDR(ia->ia_maddr);
  12830. +     sc->mem_size = memsize;
  12831. +     sc->mem_end = sc->mem_start + memsize;
  12832. +     /*
  12833. +      * We have an entire 8k window to put the transmit buffers on the
  12834. +      * 16-bit boards.  But since the 16bit 3c503's shared memory is only
  12835. +      * fast enough to overlap the loading of one full-size packet, trying
  12836. +      * to load more than 2 buffers can actually leave the transmitter idle
  12837. +      * during the load.  So 2 seems the best value.  (Although a mix of
  12838. +      * variable-sized packets might change this assumption.  Nonetheless,
  12839. +      * we optimize for linear transfers of same-size packets.)
  12840. +      */
  12841. +     if (isa16bit) {
  12842. +          if (cf->cf_flags & ED_FLAGS_NO_MULTI_BUFFERING)
  12843. +             sc->txb_cnt = 1;
  12844. +         else
  12845. +             sc->txb_cnt = 2;
  12846. +         sc->tx_page_start = ED_3COM_TX_PAGE_OFFSET_16BIT;
  12847. +         sc->rec_page_start = ED_3COM_RX_PAGE_OFFSET_16BIT;
  12848. +         sc->rec_page_stop =
  12849. +             (memsize >> ED_PAGE_SHIFT) + ED_3COM_RX_PAGE_OFFSET_16BIT;
  12850. +         sc->mem_ring = sc->mem_start;
  12851. +     } else {
  12852. +         sc->txb_cnt = 1;
  12853. +         sc->tx_page_start = ED_3COM_TX_PAGE_OFFSET_8BIT;
  12854. +         sc->rec_page_start =
  12855. +             ED_TXBUF_SIZE + ED_3COM_TX_PAGE_OFFSET_8BIT;
  12856. +         sc->rec_page_stop =
  12857. +             (memsize >> ED_PAGE_SHIFT) + ED_3COM_TX_PAGE_OFFSET_8BIT;
  12858. +         sc->mem_ring =
  12859. +             sc->mem_start + (ED_TXBUF_SIZE << ED_PAGE_SHIFT);
  12860. +     }
  12861. +     sc->isa16bit = isa16bit;
  12862. +     /*
  12863. +      * Initialize GA page start/stop registers.  Probably only needed if
  12864. +      * doing DMA, but what the Hell.
  12865. +      */
  12866. +     outb(sc->asic_addr + ED_3COM_PSTR, sc->rec_page_start);
  12867. +     outb(sc->asic_addr + ED_3COM_PSPR, sc->rec_page_stop);
  12868. +     /* Set IRQ.  3c503 only allows a choice of irq 3-5 or 9. */
  12869. +     switch (ia->ia_irq) {
  12870. +     case 9:
  12871. +         outb(sc->asic_addr + ED_3COM_IDCFR, ED_3COM_IDCFR_IRQ2);
  12872. +         break;
  12873. +     case 3:
  12874. +         outb(sc->asic_addr + ED_3COM_IDCFR, ED_3COM_IDCFR_IRQ3);
  12875. +         break;
  12876. +     case 4:
  12877. +         outb(sc->asic_addr + ED_3COM_IDCFR, ED_3COM_IDCFR_IRQ4);
  12878. +         break;
  12879. +     case 5:
  12880. +         outb(sc->asic_addr + ED_3COM_IDCFR, ED_3COM_IDCFR_IRQ5);
  12881. +         break;
  12882. +     default:
  12883. +         printf("%s: invalid irq configuration (%d) must be 3-5 or 9 for 3c503\n",
  12884. +             sc->sc_dev.dv_xname, ia->ia_irq);
  12885. +         return (0);
  12886. +     }
  12887. +     /*
  12888. +      * Initialize GA configuration register.  Set bank and enable shared
  12889. +      * mem.
  12890. +      */
  12891. +     outb(sc->asic_addr + ED_3COM_GACFR,
  12892. +         ED_3COM_GACFR_RSEL | ED_3COM_GACFR_MBS0);
  12893. +     /*
  12894. +      * Initialize "Vector Pointer" registers. These gawd-awful things are
  12895. +      * compared to 20 bits of the address on ISA, and if they match, the
  12896. +      * shared memory is disabled. We set them to 0xffff0...allegedly the
  12897. +      * reset vector.
  12898. +      */
  12899. +     outb(sc->asic_addr + ED_3COM_VPTR2, 0xff);
  12900. +     outb(sc->asic_addr + ED_3COM_VPTR1, 0xff);
  12901. +     outb(sc->asic_addr + ED_3COM_VPTR0, 0x00);
  12902. +     /* Zero memory and verify that it is clear. */
  12903. +     zero_isa(sc->mem_start, memsize);
  12904. +     for (i = 0; i < memsize; ++i)
  12905. +         if (ldb(sc->mem_start + i)) {
  12906. +             printf("%s: failed to clear shared memory at %x - check configuration\n",
  12907. +                 sc->sc_dev.dv_xname, (int)(sc->mem_start + i));
  12908. +             return (0);
  12909. +         }
  12910. +     ia->ia_msize = memsize;
  12911. +     ia->ia_iosize = ED_3COM_IO_PORTS;
  12912. +     return (1);
  12913. + }
  12914. + /*
  12915. +  * Probe and vendor-specific initialization routine for NE1000/2000 boards.
  12916. +  */
  12917. + int
  12918. + isaed_probe_Novell(sc, cf, ia)
  12919. +     struct isaed_softc *sc;
  12920. +     struct cfdata *cf;
  12921. +     struct isa_attach_args *ia;
  12922. + {
  12923. +     u_int memsize, n;
  12924. +     u_char romdata[16], isa16bit = 0, tmp;
  12925. +     static u_char test_pattern[32] = "THIS is A memory TEST pattern";
  12926. +     u_char test_buffer[32];
  12927. +     sc->asic_addr = ia->ia_iobase + ED_NOVELL_ASIC_OFFSET;
  12928. +     sc->nic_addr = ia->ia_iobase + ED_NOVELL_NIC_OFFSET;
  12929. +     /* XXX - do Novell-specific probe here */
  12930. +     /* Reset the board. */
  12931. + #ifdef GWETHER
  12932. +     outb(sc->asic_addr + ED_NOVELL_RESET, 0);
  12933. +     delay(200);
  12934. + #endif /* GWETHER */
  12935. +     tmp = inb(sc->asic_addr + ED_NOVELL_RESET);
  12936. +     /*
  12937. +      * I don't know if this is necessary; probably cruft leftover from
  12938. +      * Clarkson packet driver code. Doesn't do a thing on the boards I've
  12939. +      * tested. -DG [note that a outb(0x84, 0) seems to work here, and is
  12940. +      * non-invasive...but some boards don't seem to reset and I don't have
  12941. +      * complete documentation on what the 'right' thing to do is...so we do
  12942. +      * the invasive thing for now.  Yuck.]
  12943. +      */
  12944. +     outb(sc->asic_addr + ED_NOVELL_RESET, tmp);
  12945. +     delay(5000);
  12946. +     /*
  12947. +      * This is needed because some NE clones apparently don't reset the NIC
  12948. +      * properly (or the NIC chip doesn't reset fully on power-up)
  12949. +      * XXX - this makes the probe invasive! ...Done against my better
  12950. +      * judgement.  -DLG
  12951. +      */
  12952. +     NIC_PUT(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STP);
  12953. +     delay(5000);
  12954. +     /* Make sure that we really have an 8390 based board. */
  12955. +     if (!isaed_probe_generic8390(sc))
  12956. +         return (0);
  12957. +     sc->vendor = ED_VENDOR_NOVELL;
  12958. +     sc->mem_shared = 0;
  12959. +     sc->cr_proto = ED_CR_RD2;
  12960. +     ia->ia_msize = 0;
  12961. +     /*
  12962. +      * Test the ability to read and write to the NIC memory.  This has the
  12963. +      * side affect of determining if this is an NE1000 or an NE2000.
  12964. +      */
  12965. +     /*
  12966. +      * This prevents packets from being stored in the NIC memory when the
  12967. +      * readmem routine turns on the start bit in the CR.
  12968. +      */
  12969. +     NIC_PUT(sc, ED_P0_RCR, ED_RCR_MON);
  12970. +     /* Temporarily initialize DCR for byte operations. */
  12971. +     NIC_PUT(sc, ED_P0_DCR, ED_DCR_FT1 | ED_DCR_LS);
  12972. +     NIC_PUT(sc, ED_P0_PSTART, 8192 >> ED_PAGE_SHIFT);
  12973. +     NIC_PUT(sc, ED_P0_PSTOP, 16384 >> ED_PAGE_SHIFT);
  12974. +     sc->isa16bit = 0;
  12975. +     /*
  12976. +      * Write a test pattern in byte mode.  If this fails, then there
  12977. +      * probably isn't any memory at 8k - which likely means that the board
  12978. +      * is an NE2000.
  12979. +      */
  12980. +     isaed_pio_writemem(sc, test_pattern, 8192, sizeof(test_pattern));
  12981. +     isaed_pio_readmem(sc, 8192, test_buffer, sizeof(test_pattern));
  12982. +     if (bcmp(test_pattern, test_buffer, sizeof(test_pattern))) {
  12983. +         /* not an NE1000 - try NE2000 */
  12984. +         NIC_PUT(sc, ED_P0_DCR,
  12985. +             ED_DCR_WTS | ED_DCR_FT1 | ED_DCR_LS);
  12986. +         NIC_PUT(sc, ED_P0_PSTART, 16384 >> ED_PAGE_SHIFT);
  12987. +         NIC_PUT(sc, ED_P0_PSTOP, 32768 >> ED_PAGE_SHIFT);
  12988. +         sc->isa16bit = 1;
  12989. +         /*
  12990. +          * Write a test pattern in word mode.  If this also fails, then
  12991. +          * we don't know what this board is.
  12992. +          */
  12993. +         isaed_pio_writemem(sc, test_pattern, 16384, sizeof(test_pattern));
  12994. +         isaed_pio_readmem(sc, 16384, test_buffer, sizeof(test_pattern));
  12995. +         if (bcmp(test_pattern, test_buffer, sizeof(test_pattern)))
  12996. +             return (0); /* not an NE2000 either */
  12997. +         sc->type = ED_TYPE_NE2000;
  12998. +         sc->type_str = "NE2000";
  12999. +     } else {
  13000. +         sc->type = ED_TYPE_NE1000;
  13001. +         sc->type_str = "NE1000";
  13002. +     }
  13003. +     if (ia->ia_irq == IRQUNK) {
  13004. +         printf("%s: %s does not have soft configuration\n",
  13005. +             sc->sc_dev.dv_xname, sc->type_str);
  13006. +         return (0);
  13007. +     }
  13008. +     /* 8k of memory plus an additional 8k if 16-bit. */
  13009. +     memsize = 8192 + sc->isa16bit * 8192;
  13010. + #if 0 /* probably not useful - NE boards only come two ways */
  13011. +     /* Allow kernel config file overrides. */
  13012. +     if (ia->ia_msize)
  13013. +         memsize = ia->ia_msize;
  13014. + #endif
  13015. +     /* NIC memory doesn't start at zero on an NE board. */
  13016. +     /* The start address is tied to the bus width. */
  13017. +     sc->mem_start = (caddr_t)(8192 + sc->isa16bit * 8192);
  13018. +     sc->tx_page_start = memsize >> ED_PAGE_SHIFT;
  13019. + #ifdef GWETHER
  13020. +     {
  13021. +         int x, i, mstart = 0;
  13022. +         char pbuf0[ED_PAGE_SIZE], pbuf[ED_PAGE_SIZE], tbuf[ED_PAGE_SIZE];
  13023. +         for (i = 0; i < ED_PAGE_SIZE; i++)
  13024. +             pbuf0[i] = 0;
  13025. +         /* Search for the start of RAM. */
  13026. +         for (x = 1; x < 256; x++) {
  13027. +             ed_pio_writemem(sc, pbuf0, x << ED_PAGE_SHIFT, ED_PAGE_SIZE);
  13028. +             ed_pio_readmem(sc, x << ED_PAGE_SHIFT, tbuf, ED_PAGE_SIZE);
  13029. +             if (!bcmp(pbuf0, tbuf, ED_PAGE_SIZE)) {
  13030. +                 for (i = 0; i < ED_PAGE_SIZE; i++)
  13031. +                     pbuf[i] = 255 - x;
  13032. +                 ed_pio_writemem(sc, pbuf, x << ED_PAGE_SHIFT, ED_PAGE_SIZE);
  13033. +                 ed_pio_readmem(sc, x << ED_PAGE_SHIFT, tbuf, ED_PAGE_SIZE);
  13034. +                 if (!bcmp(pbuf, tbuf, ED_PAGE_SIZE)) {
  13035. +                     mstart = x << ED_PAGE_SHIFT;
  13036. +                     memsize = ED_PAGE_SIZE;
  13037. +                     break;
  13038. +                 }
  13039. +             }
  13040. +         }
  13041. +         if (mstart == 0) {
  13042. +             printf("%s: cannot find start of RAM\n",
  13043. +                 sc->sc_dev.dv_xname);
  13044. +             return (0);
  13045. +         }
  13046. +         /* Search for the end of RAM. */
  13047. +         for (++x; x < 256; x++) {
  13048. +             ed_pio_writemem(sc, pbuf0, x << ED_PAGE_SHIFT, ED_PAGE_SIZE);
  13049. +             ed_pio_readmem(sc, x << ED_PAGE_SHIFT, tbuf, ED_PAGE_SIZE);
  13050. +             if (!bcmp(pbuf0, tbuf, ED_PAGE_SIZE)) {
  13051. +                 for (i = 0; i < ED_PAGE_SIZE; i++)
  13052. +                     pbuf[i] = 255 - x;
  13053. +                 ed_pio_writemem(sc, pbuf, x << ED_PAGE_SHIFT, ED_PAGE_SIZE);
  13054. +                 ed_pio_readmem(sc, x << ED_PAGE_SHIFT, tbuf, ED_PAGE_SIZE);
  13055. +                 if (!bcmp(pbuf, tbuf, ED_PAGE_SIZE))
  13056. +                     memsize += ED_PAGE_SIZE;
  13057. +                 else
  13058. +                     break;
  13059. +             } else
  13060. +                 break;
  13061. +         }
  13062. +         printf("%s: RAM start %x, size %d\n",
  13063. +             sc->sc_dev.dv_xname, mstart, memsize);
  13064. +         sc->mem_start = (caddr_t)mstart;
  13065. +         sc->tx_page_start = mstart >> ED_PAGE_SHIFT;
  13066. +     }
  13067. + #endif /* GWETHER */
  13068. +     sc->mem_size = memsize;
  13069. +     sc->mem_end = sc->mem_start + memsize;
  13070. +     /*
  13071. +      * Use one xmit buffer if < 16k, two buffers otherwise (if not told
  13072. +      * otherwise).
  13073. +      */
  13074. +     if ((memsize < 16384) || (cf->cf_flags & ED_FLAGS_NO_MULTI_BUFFERING))
  13075. +         sc->txb_cnt = 1;
  13076. +     else
  13077. +         sc->txb_cnt = 2;
  13078. +     sc->rec_page_start = sc->tx_page_start + sc->txb_cnt * ED_TXBUF_SIZE;
  13079. +     sc->rec_page_stop = sc->tx_page_start + (memsize >> ED_PAGE_SHIFT);
  13080. +     sc->mem_ring =
  13081. +         sc->mem_start + ((sc->txb_cnt * ED_TXBUF_SIZE) << ED_PAGE_SHIFT);
  13082. +     isaed_pio_readmem(sc, 0, romdata, 16);
  13083. +     for (n = 0; n < ETHER_ADDR_LEN; n++)
  13084. +         sc->sc_arpcom.ac_enaddr[n] = romdata[n*(sc->isa16bit+1)];
  13085. + #ifdef GWETHER
  13086. +     if (sc->arpcom.ac_enaddr[2] == 0x86)
  13087. +         sc->type_str = "Gateway AT";
  13088. + #endif /* GWETHER */
  13089. +     /* Clear any pending interrupts that might have occurred above. */
  13090. +     NIC_PUT(sc, ED_P0_ISR, 0xff);
  13091. +     ia->ia_iosize = ED_NOVELL_IO_PORTS;
  13092. +     return (1);
  13093. + }
  13094. + /*
  13095. +  * Install interface into kernel networking data structures.
  13096. +  */
  13097. + void
  13098. + isaedattach(parent, self, aux)
  13099. +     struct device *parent, *self;
  13100. +     void *aux;
  13101. + {
  13102. +     struct isaed_softc *sc = (void *)self;
  13103. +     struct isa_attach_args *ia = aux;
  13104. +     struct cfdata *cf = sc->sc_dev.dv_cfdata;
  13105. +     struct ifnet *ifp = &sc->sc_arpcom.ac_if;
  13106. +     /* Set interface to stopped condition (reset). */
  13107. +     isaedstop(sc);
  13108. +     /* Initialize ifnet structure. */
  13109. +     ifp->if_unit = sc->sc_dev.dv_unit;
  13110. +     ifp->if_name = isaedcd.cd_name;
  13111. +     ifp->if_start = isaedstart;
  13112. +     ifp->if_ioctl = isaedioctl;
  13113. +     ifp->if_watchdog = isaedwatchdog;
  13114. +     ifp->if_flags =
  13115. +         IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST;
  13116. +     /*
  13117. +      * Set default state for LINK0 flag (used to disable the tranceiver
  13118. +      * for AUI operation), based on compile-time config option.
  13119. +      */
  13120. +     switch (sc->vendor) {
  13121. +     case ED_VENDOR_3COM:
  13122. +         if (cf->cf_flags & ED_FLAGS_DISABLE_TRANCEIVER)
  13123. +             ifp->if_flags |= IFF_LINK0;
  13124. +         break;
  13125. +     case ED_VENDOR_WD_SMC:
  13126. +         if ((sc->type & ED_WD_SOFTCONFIG) == 0)
  13127. +             break;
  13128. +         if ((inb(sc->asic_addr + ED_WD_IRR) & ED_WD_IRR_OUT2) == 0)
  13129. +             ifp->if_flags |= IFF_LINK0;
  13130. +         break;
  13131. +     }
  13132. +     /* Attach the interface. */
  13133. +     if_attach(ifp);
  13134. +     ether_ifattach(ifp);
  13135. +     /* Print additional info when attached. */
  13136. +     printf(": address %s, ", ether_sprintf(sc->sc_arpcom.ac_enaddr));
  13137. +     if (sc->type_str)
  13138. +         printf("type %s ", sc->type_str);
  13139. +     else
  13140. +         printf("type unknown (0x%x) ", sc->type);
  13141. +     printf("%s", sc->isa16bit ? "(16-bit)" : "(8-bit)");
  13142. +     switch (sc->vendor) {
  13143. +     case ED_VENDOR_WD_SMC:
  13144. +         if ((sc->type & ED_WD_SOFTCONFIG) == 0)
  13145. +             break;
  13146. +     case ED_VENDOR_3COM:
  13147. +         if (ifp->if_flags & IFF_LINK0)
  13148. +             printf(" aui");
  13149. +         else
  13150. +             printf(" bnc");
  13151. +         break;
  13152. +     }
  13153. +     printf("\n");
  13154. + #if NBPFILTER > 0
  13155. +     bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header));
  13156. + #endif
  13157. +     sc->sc_ih = isa_intr_establish(ia->ia_irq, ISA_IST_EDGE, ISA_IPL_NET,
  13158. +         isaedintr, sc);
  13159. + }
  13160. + /*
  13161. +  * Reset interface.
  13162. +  */
  13163. + void
  13164. + isaedreset(sc)
  13165. +     struct isaed_softc *sc;
  13166. + {
  13167. +     int s;
  13168. +     s = splimp();
  13169. +     isaedstop(sc);
  13170. +     isaedinit(sc);
  13171. +     splx(s);
  13172. + }
  13173. + /*
  13174. +  * Take interface offline.
  13175. +  */
  13176. + void
  13177. + isaedstop(sc)
  13178. +     struct isaed_softc *sc;
  13179. + {
  13180. +     int n = 5000;
  13181. +     /* Stop everything on the interface, and select page 0 registers. */
  13182. +     NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STP);
  13183. +     /*
  13184. +      * Wait for interface to enter stopped state, but limit # of checks to
  13185. +      * 'n' (about 5ms).  It shouldn't even take 5us on modern DS8390's, but
  13186. +      * just in case it's an old one.
  13187. +      */
  13188. +     while (((NIC_GET(sc, ED_P0_ISR) & ED_ISR_RST) == 0) && --n);
  13189. + }
  13190. + /*
  13191. +  * Device timeout/watchdog routine.  Entered if the device neglects to generate
  13192. +  * an interrupt after a transmit has been started on it.
  13193. +  */
  13194. + void
  13195. + isaedwatchdog(unit)
  13196. +     int unit;
  13197. + {
  13198. +     struct isaed_softc *sc = isaedcd.cd_devs[unit];
  13199. +     log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname);
  13200. +     ++sc->sc_arpcom.ac_if.if_oerrors;
  13201. +     isaedreset(sc);
  13202. + }
  13203. + /*
  13204. +  * Initialize device.
  13205. +  */
  13206. + void
  13207. + isaedinit(sc)
  13208. +     struct isaed_softc *sc;
  13209. + {
  13210. +     struct ifnet *ifp = &sc->sc_arpcom.ac_if;
  13211. +     int i;
  13212. +     u_char command;
  13213. +     u_long mcaf[2];
  13214. +     /*
  13215. +      * Initialize the NIC in the exact order outlined in the NS manual.
  13216. +      * This init procedure is "mandatory"...don't change what or when
  13217. +      * things happen.
  13218. +      */
  13219. +     /* Reset transmitter flags. */
  13220. +     ifp->if_timer = 0;
  13221. +     sc->txb_inuse = 0;
  13222. +     sc->txb_new = 0;
  13223. +     sc->txb_next_tx = 0;
  13224. +     /* Set interface for page 0, remote DMA complete, stopped. */
  13225. +     NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STP);
  13226. +     if (sc->isa16bit) {
  13227. +         /*
  13228. +          * Set FIFO threshold to 8, No auto-init Remote DMA, byte
  13229. +          * order=80x86, word-wide DMA xfers,
  13230. +          */
  13231. +         NIC_PUT(sc, ED_P0_DCR, ED_DCR_FT1 | ED_DCR_WTS | ED_DCR_LS);
  13232. +     } else {
  13233. +         /* Same as above, but byte-wide DMA xfers. */
  13234. +         NIC_PUT(sc, ED_P0_DCR, ED_DCR_FT1 | ED_DCR_LS);
  13235. +     }
  13236. +     /* Clear remote byte count registers. */
  13237. +     NIC_PUT(sc, ED_P0_RBCR0, 0);
  13238. +     NIC_PUT(sc, ED_P0_RBCR1, 0);
  13239. +     /* Tell RCR to do nothing for now. */
  13240. +     NIC_PUT(sc, ED_P0_RCR, ED_RCR_MON);
  13241. +     /* Place NIC in internal loopback mode. */
  13242. +     NIC_PUT(sc, ED_P0_TCR, ED_TCR_LB0);
  13243. +     /* Set lower bits of byte addressable framing to 0. */
  13244. +     if (sc->is790)
  13245. +         NIC_PUT(sc, 0x09, 0);
  13246. +     /* Initialize receive buffer ring. */
  13247. +     NIC_PUT(sc, ED_P0_BNRY, sc->rec_page_start);
  13248. +     NIC_PUT(sc, ED_P0_PSTART, sc->rec_page_start);
  13249. +     NIC_PUT(sc, ED_P0_PSTOP, sc->rec_page_stop);
  13250. +     /*
  13251. +      * Clear all interrupts.  A '1' in each bit position clears the
  13252. +      * corresponding flag.
  13253. +      */
  13254. +     NIC_PUT(sc, ED_P0_ISR, 0xff);
  13255. +     /*
  13256. +      * Enable the following interrupts: receive/transmit complete,
  13257. +      * receive/transmit error, and Receiver OverWrite.
  13258. +      *
  13259. +      * Counter overflow and Remote DMA complete are *not* enabled.
  13260. +      */
  13261. +     NIC_PUT(sc, ED_P0_IMR,
  13262. +         ED_IMR_PRXE | ED_IMR_PTXE | ED_IMR_RXEE | ED_IMR_TXEE |
  13263. +         ED_IMR_OVWE);
  13264. +     /* Program command register for page 1. */
  13265. +     NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_1 | ED_CR_STP);
  13266. +     /* Copy out our station address. */
  13267. +     for (i = 0; i < ETHER_ADDR_LEN; ++i)
  13268. +         NIC_PUT(sc, ED_P1_PAR0 + i, sc->sc_arpcom.ac_enaddr[i]);
  13269. +     /* Set multicast filter on chip. */
  13270. +     isaed_getmcaf(&sc->sc_arpcom, mcaf);
  13271. +     for (i = 0; i < 8; i++)
  13272. +         NIC_PUT(sc, ED_P1_MAR0 + i, ((u_char *)mcaf)[i]);
  13273. +     /*
  13274. +      * Set current page pointer to one page after the boundary pointer, as
  13275. +      * recommended in the National manual.
  13276. +      */
  13277. +     sc->next_packet = sc->rec_page_start + 1;
  13278. +     NIC_PUT(sc, ED_P1_CURR, sc->next_packet);
  13279. +     /* Program command register for page 0. */
  13280. +     NIC_PUT(sc, ED_P1_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STP);
  13281. +     i = ED_RCR_AB | ED_RCR_AM;
  13282. +     if (ifp->if_flags & IFF_PROMISC) {
  13283. +         /*
  13284. +          * Set promiscuous mode.  Multicast filter was set earlier so
  13285. +          * that we should receive all multicast packets.
  13286. +          */
  13287. +         i |= ED_RCR_PRO | ED_RCR_AR | ED_RCR_SEP;
  13288. +     }
  13289. +     NIC_PUT(sc, ED_P0_RCR, i);
  13290. +     /* Take interface out of loopback. */
  13291. +     NIC_PUT(sc, ED_P0_TCR, 0);
  13292. +     /*
  13293. +      * If this is a 3Com board, the tranceiver must be software enabled
  13294. +      * (there is no settable hardware default).
  13295. +      */
  13296. +     switch (sc->vendor) {
  13297. +         u_char x;
  13298. +     case ED_VENDOR_3COM:
  13299. +         if (ifp->if_flags & IFF_LINK0)
  13300. +             outb(sc->asic_addr + ED_3COM_CR, 0);
  13301. +         else
  13302. +             outb(sc->asic_addr + ED_3COM_CR, ED_3COM_CR_XSEL);
  13303. +         break;
  13304. +     case ED_VENDOR_WD_SMC:
  13305. +         if ((sc->type & ED_WD_SOFTCONFIG) == 0)
  13306. +             break;
  13307. +         x = inb(sc->asic_addr + ED_WD_IRR);
  13308. +         if (ifp->if_flags & IFF_LINK0)
  13309. +             x &= ~ED_WD_IRR_OUT2;
  13310. +         else
  13311. +             x |= ED_WD_IRR_OUT2;
  13312. +         outb(sc->asic_addr + ED_WD_IRR, x);
  13313. +         break;
  13314. +     }
  13315. +     /* Fire up the interface. */
  13316. +     NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
  13317. +     /* Set 'running' flag, and clear output active flag. */
  13318. +     ifp->if_flags |= IFF_RUNNING;
  13319. +     ifp->if_flags &= ~IFF_OACTIVE;
  13320. +     /* ...and attempt to start output. */
  13321. +     isaedstart(ifp);
  13322. + }
  13323. + /*
  13324. +  * This routine actually starts the transmission on the interface.
  13325. +  */
  13326. + static inline void
  13327. + isaed_xmit(sc)
  13328. +     struct isaed_softc *sc;
  13329. + {
  13330. +     struct ifnet *ifp = &sc->sc_arpcom.ac_if;
  13331. +     u_short len;
  13332. +     len = sc->txb_len[sc->txb_next_tx];
  13333. +     /* Set NIC for page 0 register access. */
  13334. +     NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
  13335. +     /* Set TX buffer start page. */
  13336. +     NIC_PUT(sc, ED_P0_TPSR, sc->tx_page_start +
  13337. +         sc->txb_next_tx * ED_TXBUF_SIZE);
  13338. +     /* Set TX length. */
  13339. +     NIC_PUT(sc, ED_P0_TBCR0, len);
  13340. +     NIC_PUT(sc, ED_P0_TBCR1, len >> 8);
  13341. +     /* Set page 0, remote DMA complete, transmit packet, and *start*. */
  13342. +     NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_TXP | ED_CR_STA);
  13343. +     /* Point to next transmit buffer slot and wrap if necessary. */
  13344. +     sc->txb_next_tx++;
  13345. +     if (sc->txb_next_tx == sc->txb_cnt)
  13346. +         sc->txb_next_tx = 0;
  13347. +     /* Set a timer just in case we never hear from the board again. */
  13348. +     ifp->if_timer = 2;
  13349. + }
  13350. + /*
  13351. +  * Start output on interface.
  13352. +  * We make two assumptions here:
  13353. +  *  1) that the current priority is set to splimp _before_ this code
  13354. +  *     is called *and* is returned to the appropriate priority after
  13355. +  *     return
  13356. +  *  2) that the IFF_OACTIVE flag is checked before this code is called
  13357. +  *     (i.e. that the output part of the interface is idle)
  13358. +  */
  13359. + void
  13360. + isaedstart(ifp)
  13361. +     struct ifnet *ifp;
  13362. + {
  13363. +     struct isaed_softc *sc = isaedcd.cd_devs[ifp->if_unit];
  13364. +     struct mbuf *m0, *m;
  13365. +     caddr_t buffer;
  13366. +     int len;
  13367. +     if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING)
  13368. +         return;
  13369. + outloop:
  13370. +     /* See if there is room to put another packet in the buffer. */
  13371. +     if (sc->txb_inuse == sc->txb_cnt) {
  13372. +         /* No room.  Indicate this to the outside world and exit. */
  13373. +         ifp->if_flags |= IFF_OACTIVE;
  13374. +         return;
  13375. +     }
  13376. +     IF_DEQUEUE(&ifp->if_snd, m0);
  13377. +     if (m0 == 0)
  13378. +         return;
  13379. +     /* We need to use m->m_pkthdr.len, so require the header */
  13380. +     if ((m0->m_flags & M_PKTHDR) == 0)
  13381. +         panic("edstart: no header mbuf");
  13382. + #if NBPFILTER > 0
  13383. +     /* Tap off here if there is a BPF listener. */
  13384. +     if (ifp->if_bpf)
  13385. +         bpf_mtap(ifp->if_bpf, m0);
  13386. + #endif
  13387. +     /* txb_new points to next open buffer slot. */
  13388. +     buffer = sc->mem_start + ((sc->txb_new * ED_TXBUF_SIZE) << ED_PAGE_SHIFT);
  13389. +     if (sc->mem_shared) {
  13390. +         /* Special case setup for 16 bit boards... */
  13391. +         switch (sc->vendor) {
  13392. +         /*
  13393. +          * For 16bit 3Com boards (which have 16k of memory), we
  13394. +          * have the xmit buffers in a different page of memory
  13395. +          * ('page 0') - so change pages.
  13396. +          */
  13397. +         case ED_VENDOR_3COM:
  13398. +             if (sc->isa16bit)
  13399. +                 outb(sc->asic_addr + ED_3COM_GACFR,
  13400. +                     ED_3COM_GACFR_RSEL);
  13401. +             break;
  13402. +         /*
  13403. +          * Enable 16bit access to shared memory on WD/SMC
  13404. +          * boards.
  13405. +          */
  13406. +         case ED_VENDOR_WD_SMC:
  13407. +             if (sc->isa16bit)
  13408. +                 outb(sc->asic_addr + ED_WD_LAAR,
  13409. +                     sc->wd_laar_proto | ED_WD_LAAR_M16EN);
  13410. +             outb(sc->asic_addr + ED_WD_MSR,
  13411. +                 sc->wd_msr_proto | ED_WD_MSR_MENB);
  13412. +             (void) inb(0x84);
  13413. +             (void) inb(0x84);
  13414. +             break;
  13415. +         }
  13416. +         for (len = 0; m; m = m->m_next) {
  13417. +             copy_to_isa(mtod(m, caddr_t), buffer, m->m_len);
  13418. +             buffer += m->m_len;
  13419. +                    len += m->m_len;
  13420. +         }
  13421. +         /* Restore previous shared memory access. */
  13422. +         switch (sc->vendor) {
  13423. +         case ED_VENDOR_3COM:
  13424. +             if (sc->isa16bit)
  13425. +                 outb(sc->asic_addr + ED_3COM_GACFR,
  13426. +                     ED_3COM_GACFR_RSEL | ED_3COM_GACFR_MBS0);
  13427. +             break;
  13428. +         case ED_VENDOR_WD_SMC:
  13429. +             outb(sc->asic_addr + ED_WD_MSR,
  13430. +                 sc->wd_msr_proto);
  13431. +             if (sc->isa16bit)
  13432. +                 outb(sc->asic_addr + ED_WD_LAAR,
  13433. +                     sc->wd_laar_proto);
  13434. +             (void) inb(0x84);
  13435. +             (void) inb(0x84);
  13436. +             break;
  13437. +         }
  13438. +     } else
  13439. +         len = isaed_pio_write_mbufs(sc, m0, (long)buffer);
  13440. +     m_freem(m0);
  13441. +     sc->txb_len[sc->txb_new] = max(len, ETHER_MIN_LEN);
  13442. + #ifdef DDB
  13443. +         if (sc->next_packet < sc->rec_page_start || sc->next_packet >= sc->rec_page_stop)
  13444. +             Debugger();
  13445. + #endif
  13446. +     /* Start the first packet transmitting. */
  13447. +     if (sc->txb_inuse == 0)
  13448. +         isaed_xmit(sc);
  13449. +     /* Point to next buffer slot and wrap if necessary. */
  13450. +     if (++sc->txb_new == sc->txb_cnt)
  13451. +         sc->txb_new = 0;
  13452. +     sc->txb_inuse++;
  13453. +     /* Loop back to the top to possibly buffer more packets. */
  13454. +     goto outloop;
  13455. + }
  13456. + /*
  13457. +  * Ethernet interface receiver interrupt.
  13458. +  */
  13459. + static inline void
  13460. + isaed_rint(sc)
  13461. +     struct isaed_softc *sc;
  13462. + {
  13463. +     u_char boundary, current;
  13464. +     u_short len;
  13465. +     u_char nlen;
  13466. +     struct ed_ring packet_hdr;
  13467. +     caddr_t packet_ptr;
  13468. + loop:
  13469. + #ifdef DDB
  13470. +         if (sc->next_packet < sc->rec_page_start || sc->next_packet >= sc->rec_page_stop)
  13471. +             Debugger();
  13472. + #endif
  13473. +     /* Set NIC to page 1 registers to get 'current' pointer. */
  13474. +     NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_1 | ED_CR_STA);
  13475. +     /*
  13476. +      * 'sc->next_packet' is the logical beginning of the ring-buffer - i.e.
  13477. +      * it points to where new data has been buffered.  The 'CURR' (current)
  13478. +      * register points to the logical end of the ring-buffer - i.e. it
  13479. +      * points to where additional new data will be added.  We loop here
  13480. +      * until the logical beginning equals the logical end (or in other
  13481. +      * words, until the ring-buffer is empty).
  13482. +      */
  13483. +     current = NIC_GET(sc, ED_P1_CURR);
  13484. +     if (sc->next_packet == current)
  13485. +         return;
  13486. +     /* Set NIC to page 0 registers to update boundary register. */
  13487. +     NIC_PUT(sc, ED_P1_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
  13488. +     do {
  13489. +         /* Get pointer to this buffer's header structure. */
  13490. +         packet_ptr = sc->mem_ring +
  13491. +             ((sc->next_packet - sc->rec_page_start) << ED_PAGE_SHIFT);
  13492. +         /*
  13493. +          * The byte count includes a 4 byte header that was added by
  13494. +          * the NIC.
  13495. +          */
  13496. +         if (sc->mem_shared)
  13497. +             copy_from_isa(packet_ptr, &packet_hdr,
  13498. +                 sizeof(packet_hdr));
  13499. +         else
  13500. +             isaed_pio_readmem(sc, (long)packet_ptr,
  13501. +                 (caddr_t) &packet_hdr, sizeof(packet_hdr));
  13502. +         len = itohs(packet_hdr.count);
  13503. + #ifdef ISAED_DEBUG
  13504. +         if (isaeddebug) {
  13505. +             int i;
  13506. +             u_char buf[64];
  13507. +             if (sc->mem_shared)
  13508. +                 copy_from_isa(((u_char *)packet_ptr + sizeof(struct ed_ring)), buf, 64);
  13509. +             else
  13510. +                 isaed_pio_readmem(sc, (long)packet_ptr + sizeof(struct ed_ring),
  13511. +                     (caddr_t) buf, 64);
  13512. +             printf("pkt hdr len %d hdr %02x %02x %02x %02x pkt len %d\n",
  13513. +                 sizeof(packet_hdr), ((u_char *)&packet_hdr)[0],
  13514. +                 ((u_char *)&packet_hdr)[1], ((u_char *)&packet_hdr)[2],
  13515. +                 ((u_char *)&packet_hdr)[3], len);
  13516. +             for (i = 0; i < 64; i++)
  13517. +                 printf("%02x%c", buf[i], i % 16 == 15 ? '\n' : ' ');
  13518. +         }
  13519. + #endif
  13520. +         /*
  13521. +          * Try do deal with old, buggy chips that sometimes duplicate
  13522. +          * the low byte of the length into the high byte.  We do this
  13523. +          * by simply ignoring the high byte of the length and always
  13524. +          * recalculating it.
  13525. +          *
  13526. +          * NOTE: sc->next_packet is pointing at the current packet.
  13527. +          */
  13528. +         if (packet_hdr.next_packet >= sc->next_packet)
  13529. +             nlen = (packet_hdr.next_packet - sc->next_packet);
  13530. +         else
  13531. +             nlen = ((packet_hdr.next_packet - sc->rec_page_start) +
  13532. +                 (sc->rec_page_stop - sc->next_packet));
  13533. +         --nlen;
  13534. +         if ((len & ED_PAGE_MASK) + sizeof(packet_hdr) > ED_PAGE_SIZE)
  13535. +             --nlen;
  13536. +         len = (len & ED_PAGE_MASK) | (nlen << ED_PAGE_SHIFT);
  13537. + #ifdef DIAGNOSTIC
  13538. +         if (len != itohs(packet_hdr.count)) {
  13539. +             printf("%s: length does not match next packet pointer\n",
  13540. +                 sc->sc_dev.dv_xname);
  13541. +             printf("%s: len %04x nlen %04x start %02x first %02x curr %02x next %02x stop %02x\n",
  13542. +                 sc->sc_dev.dv_xname, itohs(packet_hdr.count), len,
  13543. +                 sc->rec_page_start, sc->next_packet, current,
  13544. +                 packet_hdr.next_packet, sc->rec_page_stop);
  13545. +         }
  13546. + #endif
  13547. +         /*
  13548. +          * Be fairly liberal about what we allow as a "reasonable"
  13549. +          * length so that a [crufty] packet will make it to BPF (and
  13550. +          * can thus be analyzed).  Note that all that is really
  13551. +          * important is that we have a length that will fit into one
  13552. +          * mbuf cluster or less; the upper layer protocols can then
  13553. +          * figure out the length from their own length field(s).
  13554. +          */
  13555. +         if (len <= (MCLBYTES > ETHER_MAX_LEN ?
  13556. +                 MCLBYTES : ETHER_MAX_LEN) &&
  13557. +             packet_hdr.next_packet >= sc->rec_page_start &&
  13558. +             packet_hdr.next_packet < sc->rec_page_stop) {
  13559. +             /* Go get packet. */
  13560. +             isaedread(sc, packet_ptr + sizeof(struct ed_ring),
  13561. +                 len - sizeof(struct ed_ring));
  13562. +         } else {
  13563. +             /* Really BAD.  The ring pointers are corrupted. */
  13564. +             log(LOG_ERR,
  13565. +                 "%s: NIC memory corrupt - invalid packet length %d or pkt link %d [%d-%d)\n",
  13566. +                 sc->sc_dev.dv_xname, len, packet_hdr.next_packet,
  13567. +                 sc->rec_page_start, sc->rec_page_stop);
  13568. +             ++sc->sc_arpcom.ac_if.if_ierrors;
  13569. +             isaedreset(sc);
  13570. +             return;
  13571. +         }
  13572. +         sc->next_packet = packet_hdr.next_packet;
  13573. + #ifdef DDB
  13574. +         if (sc->next_packet < sc->rec_page_start || sc->next_packet >= sc->rec_page_stop)
  13575. +             Debugger();
  13576. + #endif
  13577. +         /*
  13578. +          * Update NIC boundary pointer - being careful to keep it one
  13579. +          * buffer behind (as recommended by NS databook).
  13580. +          */
  13581. +         boundary = sc->next_packet - 1;
  13582. +         if (boundary < sc->rec_page_start)
  13583. +             boundary = sc->rec_page_stop - 1;
  13584. +         NIC_PUT(sc, ED_P0_BNRY, boundary);
  13585. +     } while (sc->next_packet != current);
  13586. +     goto loop;
  13587. + }
  13588. + /* Ethernet interface interrupt processor. */
  13589. + int
  13590. + isaedintr(arg)
  13591. +     void *arg;
  13592. + {
  13593. +     struct isaed_softc *sc = arg;
  13594. +     struct ifnet *ifp = &sc->sc_arpcom.ac_if;
  13595. +     u_char isr;
  13596. +     /* Set NIC to page 0 registers. */
  13597. +     NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
  13598. +     isr = NIC_GET(sc, ED_P0_ISR);
  13599. +     if (!isr)
  13600. +         return (0);
  13601. +     /* Loop until there are no more new interrupts. */
  13602. +     for (;;) {
  13603. + #ifdef DDB
  13604. +         if (sc->next_packet < sc->rec_page_start || sc->next_packet >= sc->rec_page_stop)
  13605. +             Debugger();
  13606. + #endif
  13607. +         /*
  13608. +          * Reset all the bits that we are 'acknowledging' by writing a
  13609. +          * '1' to each bit position that was set.
  13610. +          * (Writing a '1' *clears* the bit.)
  13611. +          */
  13612. +         NIC_PUT(sc, ED_P0_ISR, isr);
  13613. +         /*
  13614. +          * Handle transmitter interrupts.  Handle these first because
  13615. +          * the receiver will reset the board under some conditions.
  13616. +          */
  13617. +         if (isr & (ED_ISR_PTX | ED_ISR_TXE)) {
  13618. +             u_char collisions = NIC_GET(sc, ED_P0_NCR) & 0x0f;
  13619. +             /*
  13620. +              * Check for transmit error.  If a TX completed with an
  13621. +              * error, we end up throwing the packet away.  Really
  13622. +              * the only error that is possible is excessive
  13623. +              * collisions, and in this case it is best to allow the
  13624. +              * automatic mechanisms of TCP to backoff the flow.  Of
  13625. +              * course, with UDP we're screwed, but this is expected
  13626. +              * when a network is heavily loaded.
  13627. +              */
  13628. +             (void) NIC_GET(sc, ED_P0_TSR);
  13629. +             if (isr & ED_ISR_TXE) {
  13630. +                 /*
  13631. +                  * Excessive collisions (16).
  13632. +                  */
  13633. +                 if ((NIC_GET(sc, ED_P0_TSR) & ED_TSR_ABT)
  13634. +                     && (collisions == 0)) {
  13635. +                     /*
  13636. +                      * When collisions total 16, the P0_NCR
  13637. +                      * will indicate 0, and the TSR_ABT is
  13638. +                      * set.
  13639. +                      */
  13640. +                     collisions = 16;
  13641. +                 }
  13642. +                 /* Update output errors counter. */
  13643. +                 ++ifp->if_oerrors;
  13644. +             } else {
  13645. +                 /*
  13646. +                  * Update total number of successfully
  13647. +                  * transmitted packets.
  13648. +                  */
  13649. +                 ++ifp->if_opackets;
  13650. +             }
  13651. +             /* Done with the buffer. */
  13652. +             sc->txb_inuse--;
  13653. +             /* Clear watchdog timer. */
  13654. +             ifp->if_timer = 0;
  13655. +             ifp->if_flags &= ~IFF_OACTIVE;
  13656. +             /*
  13657. +              * Add in total number of collisions on last
  13658. +              * transmission.
  13659. +              */
  13660. +             ifp->if_collisions += collisions;
  13661. +             /*
  13662. +              * Decrement buffer in-use count if not zero (can only
  13663. +              * be zero if a transmitter interrupt occured while not
  13664. +              * actually transmitting).
  13665. +              * If data is ready to transmit, start it transmitting,
  13666. +              * otherwise defer until after handling receiver.
  13667. +              */
  13668. +             if (sc->txb_inuse > 0)
  13669. +                 isaed_xmit(sc);
  13670. +         }
  13671. +         /* Handle receiver interrupts. */
  13672. +         if (isr & (ED_ISR_PRX | ED_ISR_RXE | ED_ISR_OVW)) {
  13673. +             /*
  13674. +              * Overwrite warning.  In order to make sure that a
  13675. +              * lockup of the local DMA hasn't occurred, we reset
  13676. +              * and re-init the NIC.  The NSC manual suggests only a
  13677. +              * partial reset/re-init is necessary - but some chips
  13678. +              * seem to want more.  The DMA lockup has been seen
  13679. +              * only with early rev chips - Methinks this bug was
  13680. +              * fixed in later revs.  -DG
  13681. +              */
  13682. +             if (isr & ED_ISR_OVW) {
  13683. +                 ++ifp->if_ierrors;
  13684. + #ifdef DIAGNOSTIC
  13685. +                 log(LOG_WARNING,
  13686. +                     "%s: warning - receiver ring buffer overrun\n",
  13687. +                     sc->sc_dev.dv_xname);
  13688. + #endif
  13689. +                 /* Stop/reset/re-init NIC. */
  13690. +                 isaedreset(sc);
  13691. +             } else {
  13692. +                 /*
  13693. +                  * Receiver Error.  One or more of: CRC error,
  13694. +                  * frame alignment error FIFO overrun, or
  13695. +                  * missed packet.
  13696. +                  */
  13697. +                 if (isr & ED_ISR_RXE) {
  13698. +                     ++ifp->if_ierrors;
  13699. + #ifdef ISAED_DEBUG
  13700. +                     if (isaeddebug)
  13701. +                         printf("%s: receive error %x\n",
  13702. +                             sc->sc_dev.dv_xname,
  13703. +                             NIC_GET(sc, ED_P0_RSR));
  13704. + #endif
  13705. +                 }
  13706. +                 /*
  13707. +                  * Go get the packet(s).
  13708. +                  * XXX - Doing this on an error is dubious
  13709. +                  * because there shouldn't be any data to get
  13710. +                  * (we've configured the interface to not
  13711. +                  * accept packets with errors).
  13712. +                  */
  13713. +                 /*
  13714. +                  * Enable 16bit access to shared memory first
  13715. +                  * on WD/SMC boards.
  13716. +                  */
  13717. +                 if (sc->vendor == ED_VENDOR_WD_SMC) {
  13718. +                     if (sc->isa16bit)
  13719. +                         outb(sc->asic_addr + ED_WD_LAAR,
  13720. +                             sc->wd_laar_proto | ED_WD_LAAR_M16EN);
  13721. +                     outb(sc->asic_addr + ED_WD_MSR,
  13722. +                         sc->wd_msr_proto | ED_WD_MSR_MENB);
  13723. +                     (void) inb(0x84);
  13724. +                     (void) inb(0x84);
  13725. +                 }
  13726. +                 isaed_rint(sc);
  13727. +                 /* Disable 16-bit access. */
  13728. +                 if (sc->vendor == ED_VENDOR_WD_SMC) {
  13729. +                     outb(sc->asic_addr + ED_WD_MSR,
  13730. +                         sc->wd_msr_proto);
  13731. +                     if (sc->isa16bit)
  13732. +                         outb(sc->asic_addr + ED_WD_LAAR,
  13733. +                             sc->wd_laar_proto);
  13734. +                     (void) inb(0x84);
  13735. +                     (void) inb(0x84);
  13736. +                 }
  13737. +             }
  13738. +         }
  13739. +         /*
  13740. +          * If it looks like the transmitter can take more data,    attempt
  13741. +          * to start output on the interface.  This is done after
  13742. +          * handling the receiver to give the receiver priority.
  13743. +          */
  13744. +         isaedstart(ifp);
  13745. +         /*
  13746. +          * Return NIC CR to standard state: page 0, remote DMA
  13747. +          * complete, start (toggling the TXP bit off, even if was just
  13748. +          * set in the transmit routine, is *okay* - it is 'edge'
  13749. +          * triggered from low to high).
  13750. +          */
  13751. +         NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
  13752. +         /*
  13753. +          * If the Network Talley Counters overflow, read them to reset
  13754. +          * them.  It appears that old 8390's won't clear the ISR flag
  13755. +          * otherwise - resulting in an infinite loop.
  13756. +          */
  13757. +         if (isr & ED_ISR_CNT) {
  13758. +             (void) NIC_GET(sc, ED_P0_CNTR0);
  13759. +             (void) NIC_GET(sc, ED_P0_CNTR1);
  13760. +             (void) NIC_GET(sc, ED_P0_CNTR2);
  13761. +         }
  13762. +         isr = NIC_GET(sc, ED_P0_ISR);
  13763. +         if (!isr)
  13764. +             return (1);
  13765. +     }
  13766. + }
  13767. + /*
  13768. +  * Process an ioctl request.  This code needs some work - it looks pretty ugly.
  13769. +  */
  13770. + int
  13771. + isaedioctl(ifp, cmd, data)
  13772. +     register struct ifnet *ifp;
  13773. +     u_long cmd;
  13774. +     caddr_t data;
  13775. + {
  13776. +     struct isaed_softc *sc = isaedcd.cd_devs[ifp->if_unit];
  13777. +     register struct ifaddr *ifa = (struct ifaddr *)data;
  13778. +     struct ifreq *ifr = (struct ifreq *)data;
  13779. +     int s, error = 0;
  13780. +     s = splimp();
  13781. +     switch (cmd) {
  13782. +     case SIOCSIFADDR:
  13783. +         ifp->if_flags |= IFF_UP;
  13784. +         switch (ifa->ifa_addr->sa_family) {
  13785. + #ifdef INET
  13786. +         case AF_INET:
  13787. +             isaedinit(sc);
  13788. +             arp_ifinit(&sc->sc_arpcom, ifa);
  13789. +             break;
  13790. + #endif
  13791. + #ifdef NS
  13792. +         /* XXX - This code is probably wrong. */
  13793. +         case AF_NS:
  13794. +             {
  13795. +             register struct ns_addr *ina = &IA_SNS(ifa)->sns_addr;
  13796. +             if (ns_nullhost(*ina))
  13797. +                 ina->x_host =
  13798. +                     *(union ns_host *)(sc->sc_arpcom.ac_enaddr);
  13799. +             else
  13800. +                 copy(ina->x_host.c_host,
  13801. +                     sc->sc_arpcom.ac_enaddr,
  13802. +                     sizeof(sc->sc_arpcom.ac_enaddr));
  13803. +             /* Set new address. */
  13804. +             isaedinit(sc);
  13805. +             break;
  13806. +             }
  13807. + #endif
  13808. +         default:
  13809. +             isaedinit(sc);
  13810. +             break;
  13811. +         }
  13812. +         break;
  13813. +     case SIOCSIFFLAGS:
  13814. +         if ((ifp->if_flags & IFF_UP) == 0 &&
  13815. +             (ifp->if_flags & IFF_RUNNING) != 0) {
  13816. +             /*
  13817. +              * If interface is marked down and it is running, then
  13818. +              * stop it.
  13819. +              */
  13820. +             isaedstop(sc);
  13821. +             ifp->if_flags &= ~IFF_RUNNING;
  13822. +         } else if ((ifp->if_flags & IFF_UP) != 0 &&
  13823. +                    (ifp->if_flags & IFF_RUNNING) == 0) {
  13824. +             /*
  13825. +              * If interface is marked up and it is stopped, then
  13826. +              * start it.
  13827. +              */
  13828. +             isaedinit(sc);
  13829. +         } else {
  13830. +             /*
  13831. +              * Reset the interface to pick up changes in any other
  13832. +              * flags that affect hardware registers.
  13833. +              */
  13834. +             isaedstop(sc);
  13835. +             isaedinit(sc);
  13836. +         }
  13837. +         break;
  13838. +     case SIOCADDMULTI:
  13839. +     case SIOCDELMULTI:
  13840. +         /* Update our multicast list. */
  13841. +         error = (cmd == SIOCADDMULTI) ?
  13842. +             ether_addmulti(ifr, &sc->sc_arpcom) :
  13843. +             ether_delmulti(ifr, &sc->sc_arpcom);
  13844. +         if (error == ENETRESET) {
  13845. +             /*
  13846. +              * Multicast list has changed; set the hardware filter
  13847. +              * accordingly.
  13848. +              */
  13849. +             isaedstop(sc); /* XXX for ds_setmcaf? */
  13850. +             isaedinit(sc);
  13851. +             error = 0;
  13852. +         }
  13853. +         break;
  13854. +     default:
  13855. +         error = EINVAL;
  13856. +         break;
  13857. +     }
  13858. +     splx(s);
  13859. +     return (error);
  13860. + }
  13861. + /*
  13862. +  * Retreive packet from shared memory and send to the next level up via
  13863. +  * ether_input().  If there is a BPF listener, give a copy to BPF, too.
  13864. +  */
  13865. + void
  13866. + isaedread(sc, buf, len)
  13867. +     struct isaed_softc *sc;
  13868. +     caddr_t buf;
  13869. +     int len;
  13870. + {
  13871. +     struct ifnet *ifp = &sc->sc_arpcom.ac_if;
  13872. +         struct mbuf *m;
  13873. +     struct ether_header *eh;
  13874. +     /* Pull packet off interface. */
  13875. +     m = isaedget(sc, buf, len);
  13876. +     if (m == 0) {
  13877. +         ifp->if_ierrors++;
  13878. +         return;
  13879. +     }
  13880. +     ifp->if_ipackets++;
  13881. +     /* We assume that the header fit entirely in one mbuf. */
  13882. +     eh = mtod(m, struct ether_header *);
  13883. + #if NBPFILTER > 0
  13884. +     /*
  13885. +      * Check if there's a BPF listener on this interface.
  13886. +      * If so, hand off the raw packet to BPF.
  13887. +      */
  13888. +     if (ifp->if_bpf) {
  13889. +         bpf_mtap(ifp->if_bpf, m);
  13890. +         /*
  13891. +          * Note that the interface cannot be in promiscuous mode if
  13892. +          * there are no BPF listeners.  And if we are in promiscuous
  13893. +          * mode, we have to check if this packet is really ours.
  13894. +          */
  13895. +         if ((ifp->if_flags & IFF_PROMISC) &&
  13896. +             (eh->ether_dhost[0] & 1) == 0 && /* !mcast and !bcast */
  13897. +             bcmp(eh->ether_dhost, sc->sc_arpcom.ac_enaddr,
  13898. +                 sizeof(eh->ether_dhost)) != 0) {
  13899. +             m_freem(m);
  13900. +             return;
  13901. +         }
  13902. +     }
  13903. + #endif
  13904. +     /* We assume that the header fit entirely in one mbuf. */
  13905. +     m_adj(m, sizeof(struct ether_header));
  13906. +     ether_input(ifp, eh, m);
  13907. + }
  13908. + /*
  13909. +  * Supporting routines.
  13910. +  */
  13911. + /*
  13912. +  * Given a NIC memory source address and a host memory destination address,
  13913. +  * copy 'amount' from NIC to host using Programmed I/O.  The 'amount' is
  13914. +  * rounded up to a word - okay as long as mbufs are word sized.
  13915. +  * This routine is currently Novell-specific.
  13916. +  */
  13917. + void
  13918. + isaed_pio_readmem(sc, src, dst, amount)
  13919. +     struct isaed_softc *sc;
  13920. +     u_short src;
  13921. +     caddr_t dst;
  13922. +     u_short amount;
  13923. + {
  13924. +     /* Select page 0 registers. */
  13925. +     NIC_PUT(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STA);
  13926. +     /* Round up to a word. */
  13927. +     if (amount & 1)
  13928. +         ++amount;
  13929. +     /* Set up DMA byte count. */
  13930. +     NIC_PUT(sc, ED_P0_RBCR0, amount);
  13931. +     NIC_PUT(sc, ED_P0_RBCR1, amount >> 8);
  13932. +     /* Set up source address in NIC mem. */
  13933. +     NIC_PUT(sc, ED_P0_RSAR0, src);
  13934. +     NIC_PUT(sc, ED_P0_RSAR1, src >> 8);
  13935. +     NIC_PUT(sc, ED_P0_CR, ED_CR_RD0 | ED_CR_PAGE_0 | ED_CR_STA);
  13936. +     if (sc->isa16bit)
  13937. +         insw(sc->asic_addr + ED_NOVELL_DATA, dst, amount / 2);
  13938. +     else
  13939. +         insb(sc->asic_addr + ED_NOVELL_DATA, dst, amount);
  13940. + }
  13941. + /*
  13942. +  * Stripped down routine for writing a linear buffer to NIC memory.  Only used
  13943. +  * in the probe routine to test the memory.  'len' must be even.
  13944. +  */
  13945. + void
  13946. + isaed_pio_writemem(sc, src, dst, len)
  13947. +     struct isaed_softc *sc;
  13948. +     caddr_t src;
  13949. +     u_short dst;
  13950. +     u_short len;
  13951. + {
  13952. +     int maxwait = 100; /* about 120us */
  13953. +     /* Select page 0 registers. */
  13954. +     NIC_PUT(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STA);
  13955. +     /* Reset remote DMA complete flag. */
  13956. +     NIC_PUT(sc, ED_P0_ISR, ED_ISR_RDC);
  13957. +     /* Set up DMA byte count. */
  13958. +     NIC_PUT(sc, ED_P0_RBCR0, len);
  13959. +     NIC_PUT(sc, ED_P0_RBCR1, len >> 8);
  13960. +     /* Set up destination address in NIC mem. */
  13961. +     NIC_PUT(sc, ED_P0_RSAR0, dst);
  13962. +     NIC_PUT(sc, ED_P0_RSAR1, dst >> 8);
  13963. +     /* Set remote DMA write. */
  13964. +     NIC_PUT(sc, ED_P0_CR, ED_CR_RD1 | ED_CR_PAGE_0 | ED_CR_STA);
  13965. +     if (sc->isa16bit)
  13966. +         outsw(sc->asic_addr + ED_NOVELL_DATA, src, len / 2);
  13967. +     else
  13968. +         outsb(sc->asic_addr + ED_NOVELL_DATA, src, len);
  13969. +     /*
  13970. +      * Wait for remote DMA complete.  This is necessary because on the
  13971. +      * transmit side, data is handled internally by the NIC in bursts and
  13972. +      * we can't start another remote DMA until this one completes.  Not
  13973. +      * waiting causes really bad things to happen - like the NIC
  13974. +      * irrecoverably jamming the ISA bus.
  13975. +      */
  13976. +     while (((NIC_GET(sc, ED_P0_ISR) & ED_ISR_RDC) != ED_ISR_RDC) && --maxwait);
  13977. + }
  13978. + /*
  13979. +  * Write an mbuf chain to the destination NIC memory address using programmed
  13980. +  * I/O.
  13981. +  */
  13982. + u_short
  13983. + isaed_pio_write_mbufs(sc, m, dst)
  13984. +     struct isaed_softc *sc;
  13985. +     struct mbuf *m;
  13986. +     u_short dst;
  13987. + {
  13988. +     u_short len;
  13989. +     struct mbuf *mp;
  13990. +     int maxwait = 100; /* about 120us */
  13991. +     len = m->m_pkthdr.len;
  13992. +     /* Select page 0 registers. */
  13993. +     NIC_PUT(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_PAGE_0 | ED_CR_STA);
  13994. +     /* Reset remote DMA complete flag. */
  13995. +     NIC_PUT(sc, ED_P0_ISR, ED_ISR_RDC);
  13996. +     /* Set up DMA byte count. */
  13997. +     NIC_PUT(sc, ED_P0_RBCR0, len);
  13998. +     NIC_PUT(sc, ED_P0_RBCR1, len >> 8);
  13999. +     /* Set up destination address in NIC mem. */
  14000. +     NIC_PUT(sc, ED_P0_RSAR0, dst);
  14001. +     NIC_PUT(sc, ED_P0_RSAR1, dst >> 8);
  14002. +     /* Set remote DMA write. */
  14003. +     NIC_PUT(sc, ED_P0_CR, ED_CR_RD1 | ED_CR_PAGE_0 | ED_CR_STA);
  14004. +     /*
  14005. +      * Transfer the mbuf chain to the NIC memory.
  14006. +      * 16-bit cards require that data be transferred as words, and only
  14007. +      * words, so that case requires some extra code to patch over
  14008. +      * odd-length mbufs.
  14009. +      */
  14010. +     if (!sc->isa16bit) {
  14011. +         /* NE1000s are easy. */
  14012. +         for (; m != 0; m = m->m_next) {
  14013. +             if (m->m_len) {
  14014. +                 outsb(sc->asic_addr + ED_NOVELL_DATA,
  14015. +                     mtod(m, u_char *), m->m_len);
  14016. +             }
  14017. +         }
  14018. +     } else {
  14019. +         /* NE2000s are a bit trickier. */
  14020. +         u_char *data, savebyte[2];
  14021. +         int len, wantbyte;
  14022. +         wantbyte = 0;
  14023. +         for (; m != 0; m = m->m_next) {
  14024. +             len = m->m_len;
  14025. +             if (len == 0)
  14026. +                 continue;
  14027. +             data = mtod(m, u_char *);
  14028. +             /* Finish the last word. */
  14029. +             if (wantbyte) {
  14030. +                 savebyte[1] = *data;
  14031. +                 outw(sc->asic_addr + ED_NOVELL_DATA,
  14032. +                     *(u_short *)savebyte);
  14033. +                 data++;
  14034. +                 len--;
  14035. +                 wantbyte = 0;
  14036. +             }
  14037. +             /* Output contiguous words. */
  14038. +             if (len > 1)
  14039. +                 outsw(sc->asic_addr + ED_NOVELL_DATA,
  14040. +                     data, len >> 1);
  14041. +             /* Save last byte, if necessary. */
  14042. +             if (len & 1) {
  14043. +                 data += len & ~1;
  14044. +                 savebyte[0] = *data;
  14045. +                 wantbyte = 1;
  14046. +             }
  14047. +         }
  14048. +         if (wantbyte) {
  14049. +             savebyte[1] = 0;
  14050. +             outw(sc->asic_addr + ED_NOVELL_DATA,
  14051. +                 *(u_short *)savebyte);
  14052. +         }
  14053. +     }
  14054. +     /*
  14055. +      * Wait for remote DMA complete.  This is necessary because on the
  14056. +      * transmit side, data is handled internally by the NIC in bursts and
  14057. +      * we can't start another remote DMA until this one completes.     Not
  14058. +      * waiting causes really bad things to happen - like the NIC
  14059. +      * irrecoverably jamming the ISA bus.
  14060. +      */
  14061. +     while (((NIC_GET(sc, ED_P0_ISR) & ED_ISR_RDC) != ED_ISR_RDC) && --maxwait);
  14062. +     if (!maxwait) {
  14063. +         log(LOG_WARNING,
  14064. +             "%s: remote transmit DMA failed to complete\n",
  14065. +             sc->sc_dev.dv_xname);
  14066. +         isaedreset(sc);
  14067. +     }
  14068. +     return (len);
  14069. + }
  14070. + /*
  14071. +  * Given a source and destination address, copy 'amount' of a packet from the
  14072. +  * ring buffer into a linear destination buffer.  Takes into account ring-wrap.
  14073. +  */
  14074. + static inline caddr_t
  14075. + isaed_ring_copy(sc, src, dst, amount)
  14076. +     struct isaed_softc *sc;
  14077. +     caddr_t src, dst;
  14078. +     u_short    amount;
  14079. + {
  14080. +     u_short    tmp_amount;
  14081. +     /* Does copy wrap to lower addr in ring buffer? */
  14082. +     if (src + amount > sc->mem_end) {
  14083. +         tmp_amount = sc->mem_end - src;
  14084. +         /* Copy amount up to end of NIC memory. */
  14085. +         if (sc->mem_shared)
  14086. +             copy_from_isa(src, dst, tmp_amount);
  14087. +         else
  14088. +             isaed_pio_readmem(sc, (long)src, dst, tmp_amount);
  14089. +         amount -= tmp_amount;
  14090. +         src = sc->mem_ring;
  14091. +         dst += tmp_amount;
  14092. +     }
  14093. +     if (sc->mem_shared)
  14094. +         copy_from_isa(src, dst, amount);
  14095. +     else
  14096. +         isaed_pio_readmem(sc, (long)src, dst, amount);
  14097. +     return (src + amount);
  14098. + }
  14099. + /*
  14100. +  * Copy data from receive buffer to end of mbuf chain allocate additional mbufs
  14101. +  * as needed.  Return pointer to last mbuf in chain.
  14102. +  * sc = isaed info (softc)
  14103. +  * src = pointer in isaed ring buffer
  14104. +  * dst = pointer to last mbuf in mbuf chain to copy to
  14105. +  * amount = amount of data to copy
  14106. +  */
  14107. + struct mbuf *
  14108. + isaedget(sc, src, total_len)
  14109. +     struct isaed_softc *sc;
  14110. +     caddr_t src;
  14111. +     u_short total_len;
  14112. + {
  14113. +     struct ifnet *ifp = &sc->sc_arpcom.ac_if;
  14114. +     struct mbuf *top, **mp, *m;
  14115. +     int len;
  14116. +     MGETHDR(m, M_DONTWAIT, MT_DATA);
  14117. +     if (m == 0)
  14118. +         return 0;
  14119. +     m->m_pkthdr.rcvif = ifp;
  14120. +     m->m_pkthdr.len = total_len;
  14121. +     len = MHLEN;
  14122. +     top = 0;
  14123. +     mp = ⊤
  14124. +     while (total_len > 0) {
  14125. +         if (top) {
  14126. +             MGET(m, M_DONTWAIT, MT_DATA);
  14127. +             if (m == 0) {
  14128. +                 m_freem(top);
  14129. +                 return 0;
  14130. +             }
  14131. +             len = MLEN;
  14132. +         }
  14133. +         if (total_len >= MINCLSIZE) {
  14134. +             MCLGET(m, M_DONTWAIT);
  14135. +             if (m->m_flags & M_EXT)
  14136. +                 len = MCLBYTES;
  14137. +         }
  14138. +         m->m_len = len = min(total_len, len);
  14139. +         src = isaed_ring_copy(sc, src, mtod(m, caddr_t), len);
  14140. +         total_len -= len;
  14141. +         *mp = m;
  14142. +         mp = &m->m_next;
  14143. +     }
  14144. +     return top;
  14145. + }
  14146. + /*
  14147. +  * Compute the multicast address filter from the list of multicast addresses we
  14148. +  * need to listen to.
  14149. +  */
  14150. + void
  14151. + isaed_getmcaf(ac, af)
  14152. +     struct arpcom *ac;
  14153. +     u_long *af;
  14154. + {
  14155. +     struct ifnet *ifp = &ac->ac_if;
  14156. +     struct ether_multi *enm;
  14157. +     register u_char *cp, c;
  14158. +     register u_long crc;
  14159. +     register int i, len;
  14160. +     struct ether_multistep step;
  14161. +     /*
  14162. +      * Set up multicast address filter by passing all multicast addresses
  14163. +      * through a crc generator, and then using the high order 6 bits as an
  14164. +      * index into the 64 bit logical address filter.  The high order bit
  14165. +      * selects the word, while the rest of the bits select the bit within
  14166. +      * the word.
  14167. +      */
  14168. +     if (ifp->if_flags & IFF_PROMISC) {
  14169. +         ifp->if_flags |= IFF_ALLMULTI;
  14170. +         af[0] = af[1] = 0xffffffff;
  14171. +         return;
  14172. +     }
  14173. +     af[0] = af[1] = 0;
  14174. +     ETHER_FIRST_MULTI(step, ac, enm);
  14175. +     while (enm != NULL) {
  14176. +         if (bcmp(enm->enm_addrlo, enm->enm_addrhi,
  14177. +             sizeof(enm->enm_addrlo)) != 0) {
  14178. +             /*
  14179. +              * We must listen to a range of multicast addresses.
  14180. +              * For now, just accept all multicasts, rather than
  14181. +              * trying to set only those filter bits needed to match
  14182. +              * the range.  (At this time, the only use of address
  14183. +              * ranges is for IP multicast routing, for which the
  14184. +              * range is big enough to require all bits set.)
  14185. +              */
  14186. +             ifp->if_flags |= IFF_ALLMULTI;
  14187. +             af[0] = af[1] = 0xffffffff;
  14188. +             return;
  14189. +         }
  14190. +         cp = enm->enm_addrlo;
  14191. +         crc = 0xffffffff;
  14192. +         for (len = sizeof(enm->enm_addrlo); --len >= 0;) {
  14193. +             c = *cp++;
  14194. +             for (i = 8; --i >= 0;) {
  14195. +                 if (((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01)) {
  14196. +                     crc <<= 1;
  14197. +                     crc ^= 0x04c11db6 | 1;
  14198. +                 } else
  14199. +                     crc <<= 1;
  14200. +                 c >>= 1;
  14201. +             }
  14202. +         }
  14203. +         /* Just want the 6 most significant bits. */
  14204. +         crc >>= 26;
  14205. +         /* Turn on the corresponding bit in the filter. */
  14206. +         af[crc >> 5] |= 1 << ((crc & 0x1f) ^ 0);
  14207. +         ETHER_NEXT_MULTI(step, enm);
  14208. +     }
  14209. +     ifp->if_flags &= ~IFF_ALLMULTI;
  14210. + }
  14211. *** /dev/null
  14212. --- NetBSD/src/sys/arch/amiga/isa/if_isaedreg.h
  14213. ***************
  14214. *** 0 ****
  14215. --- 1,398 ----
  14216. + /*    $NetBSD: if_isaedreg.h,v 1.12 1994/10/27 04:17:23 cgd Exp $    */
  14217. + /*
  14218. +  * National Semiconductor DS8390 NIC register definitions.
  14219. +  *
  14220. +  * Copyright (C) 1993, David Greenman.  This software may be used, modified,
  14221. +  * copied, distributed, and sold, in both source and binary form provided that
  14222. +  * the above copyright and these terms are retained.  Under no circumstances is
  14223. +  * the author responsible for the proper functioning of this software, nor does
  14224. +  * the author assume any responsibility for damages incurred with its use.
  14225. +  */
  14226. + /*
  14227. +  * Vendor types
  14228. +  */
  14229. + #define ED_VENDOR_WD_SMC    0x00    /* Western Digital/SMC */
  14230. + #define ED_VENDOR_3COM        0x01    /* 3Com */
  14231. + #define ED_VENDOR_NOVELL    0x02    /* Novell */
  14232. + /*
  14233. +  * Compile-time config flags
  14234. +  */
  14235. + /*
  14236. +  * This sets the default for enabling/disablng the tranceiver.
  14237. +  */
  14238. + #define ED_FLAGS_DISABLE_TRANCEIVER    0x0001
  14239. + /*
  14240. +  * This forces the board to be used in 8/16-bit mode even if it autoconfigs
  14241. +  * differently.
  14242. +  */
  14243. + #define ED_FLAGS_FORCE_8BIT_MODE    0x0002
  14244. + #define ED_FLAGS_FORCE_16BIT_MODE    0x0004
  14245. + /*
  14246. +  * This disables the use of double transmit buffers.
  14247. +  */
  14248. + #define ED_FLAGS_NO_MULTI_BUFFERING    0x0008
  14249. + /*
  14250. +  * This forces all operations with the NIC memory to use Programmed I/O (i.e.
  14251. +  * not via shared memory).
  14252. +  */
  14253. + #define ED_FLAGS_FORCE_PIO        0x0010
  14254. + /*
  14255. +  *        Definitions for Western digital/SMC WD80x3 series ASIC
  14256. +  */
  14257. + /*
  14258. +  * Memory Select Register (MSR)
  14259. +  */
  14260. + #define ED_WD_MSR    0
  14261. + /* next three definitions for Toshiba */
  14262. + #define    ED_WD_MSR_POW    0x02    /* 0 = power save, 1 = normal (R/W) */
  14263. + #define    ED_WD_MSR_BSY    0x04    /* gate array busy (R) */
  14264. + #define    ED_WD_MSR_LEN    0x20    /* 0 = 16-bit, 1 = 8-bit (R/W) */
  14265. + #define ED_WD_MSR_ADDR    0x3f    /* Memory decode bits 18-13 */
  14266. + #define ED_WD_MSR_MENB    0x40    /* Memory enable */
  14267. + #define ED_WD_MSR_RST    0x80    /* Reset board */
  14268. + /*
  14269. +  * Interface Configuration Register (ICR)
  14270. +  */
  14271. + #define ED_WD_ICR    1
  14272. + #define ED_WD_ICR_16BIT    0x01    /* 16-bit interface */
  14273. + #define ED_WD_ICR_OAR    0x02    /* select register (0=BIO 1=EAR) */
  14274. + #define ED_WD_ICR_IR2    0x04    /* high order bit of encoded IRQ */
  14275. + #define ED_WD_ICR_MSZ    0x08    /* memory size (0=8k 1=32k) */
  14276. + #define ED_WD_ICR_RLA    0x10    /* recall LAN address */
  14277. + #define ED_WD_ICR_RX7    0x20    /* recall all but i/o and LAN address */
  14278. + #define    ED_WD_ICR_RIO    0x40    /* recall i/o address */
  14279. + #define ED_WD_ICR_STO    0x80    /* store to non-volatile memory */
  14280. + #ifdef TOSH_ETHER
  14281. + #define    ED_WD_ICR_MEM    0xe0    /* shared mem address A15-A13 (R/W) */
  14282. + #define    ED_WD_ICR_MSZ1    0x0f    /* memory size, 0x08 = 64K, 0x04 = 32K,
  14283. +                    0x02 = 16K, 0x01 = 8K */
  14284. +                 /* 64K can only be used if mem address
  14285. +                    above 1MB */
  14286. +                 /* IAR holds address A23-A16 (R/W) */
  14287. + #endif
  14288. + /*
  14289. +  * IO Address Register (IAR)
  14290. +  */
  14291. + #define ED_WD_IAR    2
  14292. + /*
  14293. +  * EEROM Address Register
  14294. +  */
  14295. + #define ED_WD_EAR    3
  14296. + /*
  14297. +  * Interrupt Request Register (IRR)
  14298. +  */
  14299. + #define ED_WD_IRR    4
  14300. + #define    ED_WD_IRR_0WS    0x01    /* use 0 wait-states on 8 bit bus */
  14301. + #define ED_WD_IRR_OUT1    0x02    /* WD83C584 pin 1 output */
  14302. + #define ED_WD_IRR_OUT2    0x04    /* WD83C584 pin 2 output */
  14303. + #define ED_WD_IRR_OUT3    0x08    /* WD83C584 pin 3 output */
  14304. + #define ED_WD_IRR_FLASH    0x10    /* Flash RAM is in the ROM socket */
  14305. + /*
  14306. +  * The three bits of the encoded IRQ are decoded as follows:
  14307. +  *
  14308. +  * IR2 IR1 IR0  IRQ
  14309. +  *  0   0   0   2/9
  14310. +  *  0   0   1   3
  14311. +  *  0   1   0   5
  14312. +  *  0   1   1   7
  14313. +  *  1   0   0   10
  14314. +  *  1   0   1   11
  14315. +  *  1   1   0   15
  14316. +  *  1   1   1   4
  14317. +  */
  14318. + #define ED_WD_IRR_IR0    0x20    /* bit 0 of encoded IRQ */
  14319. + #define ED_WD_IRR_IR1    0x40    /* bit 1 of encoded IRQ */
  14320. + #define ED_WD_IRR_IEN    0x80    /* Interrupt enable */
  14321. + /*
  14322. +  * LA Address Register (LAAR)
  14323. +  */
  14324. + #define ED_WD_LAAR    5
  14325. + #define ED_WD_LAAR_ADDRHI    0x1f    /* bits 23-19 of RAM address */
  14326. + #define ED_WD_LAAR_0WS16    0x20    /* enable 0 wait-states on 16 bit bus */
  14327. + #define ED_WD_LAAR_L16EN    0x40    /* enable 16-bit operation */
  14328. + #define ED_WD_LAAR_M16EN    0x80    /* enable 16-bit memory access */
  14329. + /* i/o base offset to station address/card-ID PROM */
  14330. + #define ED_WD_PROM    8
  14331. + /*
  14332. +  *    83C790 specific registers
  14333. +  */
  14334. + /*
  14335. +  * Hardware Support Register (HWR) ('790)
  14336. +  */
  14337. + #define    ED_WD790_HWR    4
  14338. + #define    ED_WD790_HWR_RST    0x10    /* hardware reset */
  14339. + #define    ED_WD790_HWR_LPRM    0x40    /* LAN PROM select */
  14340. + #define    ED_WD790_HWR_SWH    0x80    /* switch register set */
  14341. + /*
  14342. +  * ICR790 Interrupt Control Register for the 83C790
  14343. +  */
  14344. + #define    ED_WD790_ICR    6
  14345. + #define    ED_WD790_ICR_EIL    0x01    /* enable interrupts */
  14346. + /*
  14347. +  * General Control Register (GCR)
  14348. +  * Eanbled with SWH bit == 1 in HWR register
  14349. +  */
  14350. + #define    ED_WD790_GCR    0x0d
  14351. + #define    ED_WD790_GCR_IR0    0x04    /* bit 0 of encoded IRQ */
  14352. + #define    ED_WD790_GCR_IR1    0x08    /* bit 1 of encoded IRQ */
  14353. + #define    ED_WD790_GCR_ZWSEN    0x20    /* zero wait state enable */
  14354. + #define    ED_WD790_GCR_IR2    0x40    /* bit 2 of encoded IRQ */
  14355. + /*
  14356. +  * The three bits of the encoded IRQ are decoded as follows:
  14357. +  *
  14358. +  * IR2 IR1 IR0  IRQ
  14359. +  *  0   0   0   none
  14360. +  *  0   0   1   9
  14361. +  *  0   1   0   3
  14362. +  *  0   1   1   5
  14363. +  *  1   0   0   7
  14364. +  *  1   0   1   10
  14365. +  *  1   1   0   11
  14366. +  *  1   1   1   15
  14367. +  */
  14368. + /* i/o base offset to CARD ID */
  14369. + #define ED_WD_CARD_ID    ED_WD_PROM+6
  14370. + /* Board type codes in card ID */
  14371. + #define ED_TYPE_WD8003S        0x02
  14372. + #define ED_TYPE_WD8003E        0x03
  14373. + #define ED_TYPE_WD8013EBT    0x05
  14374. + #define    ED_TYPE_TOSHIBA1    0x11    /* named PCETA1 */
  14375. + #define    ED_TYPE_TOSHIBA2    0x12    /* named PCETA2 */
  14376. + #define    ED_TYPE_TOSHIBA3    0x13    /* named PCETB */
  14377. + #define    ED_TYPE_TOSHIBA4    0x14    /* named PCETC */
  14378. + #define    ED_TYPE_WD8003W        0x24
  14379. + #define    ED_TYPE_WD8003EB    0x25
  14380. + #define    ED_TYPE_WD8013W        0x26
  14381. + #define ED_TYPE_WD8013EP    0x27
  14382. + #define ED_TYPE_WD8013WC    0x28
  14383. + #define ED_TYPE_WD8013EPC    0x29
  14384. + #define    ED_TYPE_SMC8216T    0x2a
  14385. + #define    ED_TYPE_SMC8216C    0x2b
  14386. + #define ED_TYPE_WD8013EBP    0x2c
  14387. + /* Bit definitions in card ID */
  14388. + #define    ED_WD_REV_MASK        0x1f    /* Revision mask */
  14389. + #define    ED_WD_SOFTCONFIG    0x20    /* Soft config */
  14390. + #define    ED_WD_LARGERAM        0x40    /* Large RAM */
  14391. + #define    ED_MICROCHANEL        0x80    /* Microchannel bus (vs. isa) */
  14392. + /*
  14393. +  * Checksum total.  All 8 bytes in station address PROM will add up to this.
  14394. +  */
  14395. + #ifdef TOSH_ETHER
  14396. + #define ED_WD_ROM_CHECKSUM_TOTAL    0xA5
  14397. + #else
  14398. + #define ED_WD_ROM_CHECKSUM_TOTAL    0xFF
  14399. + #endif
  14400. + #define ED_WD_NIC_OFFSET    0x10    /* I/O base offset to NIC */
  14401. + #define ED_WD_ASIC_OFFSET    0    /* I/O base offset to ASIC */
  14402. + #define ED_WD_IO_PORTS        32    /* # of i/o addresses used */
  14403. + #define ED_WD_PAGE_OFFSET    0    /* page offset for NIC access to mem */
  14404. + /*
  14405. +  *            Definitions for 3Com 3c503
  14406. +  */
  14407. + #define ED_3COM_NIC_OFFSET    0
  14408. + #define ED_3COM_ASIC_OFFSET    0x400    /* offset to nic i/o regs */
  14409. + /*
  14410. +  * XXX - The I/O address range is fragmented in the 3c503; this is the
  14411. +  *    number of regs at iobase.
  14412. +  */
  14413. + #define ED_3COM_IO_PORTS    16    /* # of i/o addresses used */
  14414. + /* tx memory starts in second bank on 8bit cards */
  14415. + #define ED_3COM_TX_PAGE_OFFSET_8BIT    0x20
  14416. + /* tx memory starts in first bank on 16bit cards */
  14417. + #define ED_3COM_TX_PAGE_OFFSET_16BIT    0x0
  14418. + /* ...and rx memory starts in second bank */
  14419. + #define ED_3COM_RX_PAGE_OFFSET_16BIT    0x20
  14420. + /*
  14421. +  * Page Start Register.  Must match PSTART in NIC.
  14422. +  */
  14423. + #define ED_3COM_PSTR        0
  14424. + /*
  14425. +  * Page Stop Register.  Must match PSTOP in NIC.
  14426. +  */
  14427. + #define ED_3COM_PSPR        1
  14428. + /*
  14429. +  * DrQ Timer Register.  Determines number of bytes to be transfered during a
  14430. +  * DMA burst.
  14431. +  */
  14432. + #define ED_3COM_DQTR        2
  14433. + /*
  14434. +  * Base Configuration Register.  Read-only register which contains the
  14435. +  * board-configured I/O base address of the adapter.  Bit encoded.
  14436. +  */
  14437. + #define ED_3COM_BCFR        3
  14438. + /*
  14439. +  * EPROM Configuration Register.  Read-only register which contains the
  14440. +  * board-configured memory base address.  Bit encoded.
  14441. +  */
  14442. + #define ED_3COM_PCFR        4
  14443. + /*
  14444. +  * GA Configuration Register.  Gate-Array Configuration Register.
  14445. +  *
  14446. +  * mbs2  mbs1  mbs0    start address
  14447. +  *  0     0     0    0x0000
  14448. +  *  0     0     1    0x2000
  14449. +  *  0     1     0    0x4000
  14450. +  *  0     1     1    0x6000
  14451. +  *
  14452. +  * Note that with adapters with only 8K, the setting for 0x2000 must always be
  14453. +  * used.
  14454. +  */
  14455. + #define ED_3COM_GACFR        5
  14456. + #define ED_3COM_GACFR_MBS0    0x01
  14457. + #define ED_3COM_GACFR_MBS1    0x02
  14458. + #define ED_3COM_GACFR_MBS2    0x04
  14459. + #define ED_3COM_GACFR_RSEL    0x08    /* enable shared memory */
  14460. + #define ED_3COM_GACFR_TEST    0x10    /* for GA testing */
  14461. + #define ED_3COM_GACFR_OWS    0x20    /* select 0WS access to GA */
  14462. + #define ED_3COM_GACFR_TCM    0x40    /* Mask DMA interrupts */
  14463. + #define ED_3COM_GACFR_NIM    0x80    /* Mask NIC interrupts */
  14464. + /*
  14465. +  * Control Register.  Miscellaneous control functions.
  14466. +  */
  14467. + #define ED_3COM_CR        6
  14468. + #define ED_3COM_CR_RST        0x01    /* Reset GA and NIC */
  14469. + #define ED_3COM_CR_XSEL        0x02    /* Transceiver select.  BNC=1(def) AUI=0 */
  14470. + #define ED_3COM_CR_EALO        0x04    /* window EA PROM 0-15 to I/O base */
  14471. + #define ED_3COM_CR_EAHI        0x08    /* window EA PROM 16-31 to I/O base */
  14472. + #define ED_3COM_CR_SHARE    0x10    /* select interrupt sharing option */
  14473. + #define ED_3COM_CR_DBSEL    0x20    /* Double buffer select */
  14474. + #define ED_3COM_CR_DDIR        0x40    /* DMA direction select */
  14475. + #define ED_3COM_CR_START    0x80    /* Start DMA controller */
  14476. + /*
  14477. +  * Status Register.  Miscellaneous status information.
  14478. +  */
  14479. + #define ED_3COM_STREG        7
  14480. + #define ED_3COM_STREG_REV    0x07    /* GA revision */
  14481. + #define ED_3COM_STREG_DIP    0x08    /* DMA in progress */
  14482. + #define ED_3COM_STREG_DTC    0x10    /* DMA terminal count */
  14483. + #define ED_3COM_STREG_OFLW    0x20    /* Overflow */
  14484. + #define ED_3COM_STREG_UFLW    0x40    /* Underflow */
  14485. + #define ED_3COM_STREG_DPRDY    0x80    /* Data port ready */
  14486. + /*
  14487. +  * Interrupt/DMA Configuration Register
  14488. +  */
  14489. + #define ED_3COM_IDCFR        8
  14490. + #define ED_3COM_IDCFR_DRQ    0x07    /* DMA request */
  14491. + #define ED_3COM_IDCFR_UNUSED    0x08    /* not used */
  14492. + #if 0
  14493. + #define ED_3COM_IDCFR_IRQ    0xF0    /* Interrupt request */
  14494. + #else
  14495. + #define ED_3COM_IDCFR_IRQ2    0x10    /* Interrupt request 2 select */
  14496. + #define ED_3COM_IDCFR_IRQ3    0x20    /* Interrupt request 3 select */
  14497. + #define ED_3COM_IDCFR_IRQ4    0x40    /* Interrupt request 4 select */
  14498. + #define ED_3COM_IDCFR_IRQ5    0x80    /* Interrupt request 5 select */
  14499. + #endif
  14500. + /*
  14501. +  * DMA Address Register MSB
  14502. +  */
  14503. + #define ED_3COM_DAMSB        9
  14504. + /*
  14505. +  * DMA Address Register LSB
  14506. +  */
  14507. + #define ED_3COM_DALSB        0x0a
  14508. + /*
  14509. +  * Vector Pointer Register 2
  14510. +  */
  14511. + #define ED_3COM_VPTR2        0x0b
  14512. + /*
  14513. +  * Vector Pointer Register 1
  14514. +  */
  14515. + #define ED_3COM_VPTR1        0x0c
  14516. + /*
  14517. +  * Vector Pointer Register 0
  14518. +  */
  14519. + #define ED_3COM_VPTR0        0x0d
  14520. + /*
  14521. +  * Register File Access MSB
  14522. +  */
  14523. + #define ED_3COM_RFMSB        0x0e
  14524. + /*
  14525. +  * Register File Access LSB
  14526. +  */
  14527. + #define ED_3COM_RFLSB        0x0f
  14528. + /*
  14529. +  *         Definitions for Novell NE1000/2000 boards
  14530. +  */
  14531. + /*
  14532. +  * Board type codes
  14533. +  */
  14534. + #define ED_TYPE_NE1000        0x01
  14535. + #define ED_TYPE_NE2000        0x02
  14536. + /*
  14537. +  * Register offsets/total
  14538. +  */
  14539. + #define ED_NOVELL_NIC_OFFSET    0x00
  14540. + #define ED_NOVELL_ASIC_OFFSET    0x10
  14541. + #define ED_NOVELL_IO_PORTS    32
  14542. + /*
  14543. +  * Remote DMA data register; for reading or writing to the NIC mem via
  14544. +  * programmed I/O (offset from ASIC base).
  14545. +  */
  14546. + #define ED_NOVELL_DATA        0x00
  14547. + /*
  14548. +  * Reset register; reading from this register causes a board reset.
  14549. +  */
  14550. + #define ED_NOVELL_RESET        0x0f
  14551. *** /dev/null
  14552. --- NetBSD/src/sys/arch/amiga/isa/isa_intr.h
  14553. ***************
  14554. *** 0 ****
  14555. --- 1,58 ----
  14556. + /*    $NetBSD: isa_intr.h,v 1.1 1995/08/02 14:44:57 niklas Exp $    */
  14557. + /*
  14558. +  * Copyright (c) 1995 Niklas Hallqvist.
  14559. +  * All rights reserved.
  14560. +  *
  14561. +  * Copyright (c) 1995 Carnegie-Mellon University.
  14562. +  * All rights reserved.
  14563. +  *
  14564. +  * Authors: Chris G. Demetriou, Niklas Hallqvist.
  14565. +  * 
  14566. +  * Permission to use, copy, modify and distribute this software and
  14567. +  * its documentation is hereby granted, provided that both the copyright
  14568. +  * notice and this permission notice appear in all copies of the
  14569. +  * software, derivative works or modified versions, and any portions
  14570. +  * thereof, and that both notices appear in supporting documentation.
  14571. +  * 
  14572. +  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 
  14573. +  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 
  14574. +  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  14575. +  * 
  14576. +  * Carnegie Mellon requests users of this software to return to
  14577. +  *
  14578. +  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
  14579. +  *  School of Computer Science
  14580. +  *  Carnegie Mellon University
  14581. +  *  Pittsburgh PA 15213-3890
  14582. +  *
  14583. +  * any improvements or extensions that they make and grant Carnegie the
  14584. +  * rights to redistribute these changes.
  14585. +  */
  14586. + /* Prototypes for ISA-ish I/O interrupt functions. */
  14587. + /*
  14588. +  * XXX
  14589. +  * XXX THIS WILL LIKELY HAVE TO BE COMPLETELY CHANGED.
  14590. +  * XXX
  14591. +  */
  14592. + struct    isa_intr_fcns {
  14593. +     void    (*isa_intr_setup) __P((void));
  14594. +     void    *(*isa_intr_establish) __P((int irq, isa_intrtype type,
  14595. +             isa_intrlevel level, int (*ih_fun)(void *), void *ih_arg));
  14596. +     void    (*isa_intr_disestablish) __P((void *handler));
  14597. +     void    (*isa_iointr) __P((void *framep, int vec));
  14598. + };
  14599. + /*
  14600. +  * Global which tells which set of functions are correct
  14601. +  * for this machine.
  14602. +  */
  14603. + struct    isa_intr_fcns *isa_intr_fcns;
  14604. + extern struct isa_intr_fcns ggbus_intr_fcns;
  14605. + extern struct isa_intr_fcns cross_intr_fcns;
  14606. *** /dev/null
  14607. --- NetBSD/src/sys/arch/amiga/isa/isa_machdep.c
  14608. ***************
  14609. *** 0 ****
  14610. --- 1,162 ----
  14611. + /*    $NetBSD: isa_machdep.c,v 1.1 1995/08/02 14:10:17 niklas Exp $    */
  14612. + /*
  14613. +  * Copyright (c) 1995 Niklas Hallqvist
  14614. +  * All rights reserved.
  14615. +  *
  14616. +  * Redistribution and use in source and binary forms, with or without
  14617. +  * modification, are permitted provided that the following conditions
  14618. +  * are met:
  14619. +  * 1. Redistributions of source code must retain the above copyright
  14620. +  *    notice, this list of conditions and the following disclaimer.
  14621. +  * 2. Redistributions in binary form must reproduce the above copyright
  14622. +  *    notice, this list of conditions and the following disclaimer in the
  14623. +  *    documentation and/or other materials provided with the distribution.
  14624. +  * 3. All advertising materials mentioning features or use of this software
  14625. +  *    must display the following acknowledgement:
  14626. +  *      This product includes software developed by Niklas Hallqvist.
  14627. +  * 4. The name of the author may not be used to endorse or promote products
  14628. +  *    derived from this software without specific prior written permission
  14629. +  *
  14630. +  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  14631. +  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  14632. +  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  14633. +  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  14634. +  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  14635. +  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  14636. +  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  14637. +  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14638. +  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  14639. +  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14640. +  */
  14641. + #include <sys/param.h>
  14642. + #include <sys/device.h>
  14643. + #include <sys/malloc.h>
  14644. + #include <dev/isa/isavar.h>
  14645. + #include <machine/pio.h>
  14646. + #include <amiga/amiga/device.h>
  14647. + #include <amiga/isa/isa_intr.h>
  14648. + void    isaattach __P((struct device *, struct device *, void *));
  14649. + int    isamatch __P((struct device *, void *, void *));
  14650. + /*
  14651. +  * After careful thought about this issue I decided that allowing only
  14652. +  * one isabus configured into a system would be sufficient.  I'm not
  14653. +  * lazy, I did the original design with possibilities of multiple ISA
  14654. +  * busses, but that made porting of existing drivers a bit harder and
  14655. +  * error-prone, as well as I had to write obfuscated code.  This
  14656. +  * solution is more in the spirit of KISS.  --niklas@appli.se
  14657. +  */
  14658. + struct isa_link *isa;
  14659. + int isadebug = 0;
  14660. + struct cfdriver isacd = {
  14661. +     NULL, "isa", isamatch, isaattach,
  14662. +     DV_DULL, sizeof(struct device), 1
  14663. + };
  14664. + int
  14665. + isamatch(parent, cfdata, aux)
  14666. +     struct device *parent;
  14667. +     void *cfdata, *aux;
  14668. + {
  14669. +     struct cfdata *cf = cfdata;
  14670. + #ifdef DEBUG
  14671. +     if (isadebug)
  14672. +         printf(" isamatch");
  14673. + #endif
  14674. +     /* See if the unit number is valid. */
  14675. +     if (cf->cf_unit > 0)
  14676. +         return (0);
  14677. +     return (1);
  14678. + }
  14679. + void
  14680. + isaattach(parent, self, aux)
  14681. +     struct device *parent, *self;
  14682. +     void *aux;
  14683. + {
  14684. +     struct isa_softc *sc = (struct isa_softc *)self;
  14685. +     isa = (struct isa_link *)aux;
  14686. +     printf("\n");
  14687. +     TAILQ_INIT (&sc->sc_subdevs);
  14688. +     config_scan(isascan, self);
  14689. + }
  14690. + void *
  14691. + isa_intr_establish(intr, type, level, ih_fun, ih_arg)
  14692. +     int intr;
  14693. +     isa_intrtype type;
  14694. +     isa_intrlevel level;
  14695. +     int (*ih_fun)(void *);
  14696. +     void *ih_arg;
  14697. + {
  14698. +     return (*isa_intr_fcns->isa_intr_establish)(intr, type, level,
  14699. +         ih_fun, ih_arg);
  14700. + }
  14701. + void
  14702. + isa_intr_disestablish(handler)
  14703. +     void *handler;
  14704. + {
  14705. +     (*isa_intr_fcns->isa_intr_disestablish)(handler);
  14706. + }
  14707. + void
  14708. + isa_outsb(port, addr, cnt)
  14709. +     int port;
  14710. +     void *addr;
  14711. +     int cnt;
  14712. + {
  14713. +     u_int8_t *p = addr;
  14714. +     while (cnt--)
  14715. +         outb(port, *p++);
  14716. + }
  14717. + void
  14718. + isa_insb(port, addr, cnt)
  14719. +     int port;
  14720. +     void *addr;
  14721. +     int cnt;
  14722. + {
  14723. +     u_int8_t *p = addr;
  14724. +     while (cnt--)
  14725. +         *p++ = inb(port);
  14726. + }
  14727. + void
  14728. + isa_outsw(port, addr, cnt)
  14729. +     int port;
  14730. +     void *addr;
  14731. +     int cnt;
  14732. + {
  14733. +     u_int16_t *p = addr;
  14734. +     while (cnt--)
  14735. +         outw(port, *p++);
  14736. + }
  14737. + void
  14738. + isa_insw(port, addr, cnt)
  14739. +     int port;
  14740. +     void *addr;
  14741. +     int cnt;
  14742. + {
  14743. +     u_int16_t *p = addr;
  14744. +     while (cnt--)
  14745. +         *p++ = inw(port);
  14746. + }
  14747. *** /dev/null
  14748. --- NetBSD/src/sys/arch/amiga/isa/isa_machdep.h
  14749. ***************
  14750. *** 0 ****
  14751. --- 1,192 ----
  14752. + /*    $NetBSD: isa_machdep.h,v 1.1 1995/07/21 23:07:17 niklas Exp $    */
  14753. + /*
  14754. +  * Copyright (c) 1995 Niklas Hallqvist
  14755. +  * All rights reserved.
  14756. +  *
  14757. +  * Redistribution and use in source and binary forms, with or without
  14758. +  * modification, are permitted provided that the following conditions
  14759. +  * are met:
  14760. +  * 1. Redistributions of source code must retain the above copyright
  14761. +  *    notice, this list of conditions and the following disclaimer.
  14762. +  * 2. Redistributions in binary form must reproduce the above copyright
  14763. +  *    notice, this list of conditions and the following disclaimer in the
  14764. +  *    documentation and/or other materials provided with the distribution.
  14765. +  * 3. All advertising materials mentioning features or use of this software
  14766. +  *    must display the following acknowledgement:
  14767. +  *      This product includes software developed by Niklas Hallqvist.
  14768. +  * 4. The name of the author may not be used to endorse or promote products
  14769. +  *    derived from this software without specific prior written permission
  14770. +  *
  14771. +  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  14772. +  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  14773. +  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  14774. +  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  14775. +  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  14776. +  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  14777. +  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  14778. +  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14779. +  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  14780. +  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14781. +  */
  14782. + #ifndef _ISA_MACHDEP_H_
  14783. + #define _ISA_MACHDEP_H_
  14784. + #include <machine/endian.h>
  14785. + void    isa_insb __P((int port, void *addr, int));
  14786. + void    isa_outsb __P((int port, void *addr, int));
  14787. + void    isa_insw __P((int port, void *addr, int));
  14788. + void    isa_outsw __P((int port, void *addr, int));
  14789. + /*
  14790. +  * The link between the ISA device drivers and the bridgecard used.
  14791. +  */
  14792. + struct isa_link {
  14793. +     struct    device *il_dev;
  14794. +     void    (*il_stb)(struct device *, int, u_char);
  14795. +     u_char    (*il_ldb)(struct device *, int);
  14796. +     void    (*il_stw)(struct device *, int, u_short);
  14797. +     u_short    (*il_ldw)(struct device *, int);
  14798. + };
  14799. + extern struct isa_link *isa;
  14800. + extern struct cfdriver isacd;
  14801. + static __inline void
  14802. + stb(addr, val)
  14803. +     int addr;
  14804. +     u_char val;
  14805. + {
  14806. +     (*isa->il_stb)(isa->il_dev, addr, val);
  14807. + }
  14808. + static __inline u_char
  14809. + ldb(addr)
  14810. +     int addr;
  14811. + {
  14812. +     return (*isa->il_ldb)(isa->il_dev, addr);
  14813. + }
  14814. + static __inline void
  14815. + stw(addr, val)
  14816. +     int addr;
  14817. +     u_short val;
  14818. + {
  14819. +     (*isa->il_stw)(isa->il_dev, addr, val);
  14820. + }
  14821. + static __inline u_short
  14822. + ldw(addr)
  14823. +     int addr;
  14824. + {
  14825. +     return (*isa->il_ldw)(isa->il_dev, addr);
  14826. + }
  14827. + /*
  14828. +  * Should these be out-of-line instead?  If so, move them to isa.c!
  14829. +  * How about unaligned word accesses?  Does the '020 allow them?  If not
  14830. +  * we have to do odd to even moves and vice versa bytewise instead of
  14831. +  * wordwise.
  14832. +  */
  14833. + static __inline void
  14834. + copy_from_isa (void *from, void *to, int cnt)
  14835. + {
  14836. +     int a = (int)from;
  14837. +     if (a & 1 && cnt) {
  14838. +         *(u_char *)to = ldb(a++);
  14839. +         to = ((u_char *)to) + 1;
  14840. +         cnt--;
  14841. +     }
  14842. +     /* Maybe use Duff's device here... */
  14843. +     while (cnt > 1) {
  14844. +         *(u_short *)to = ldw(a);
  14845. +         a += sizeof(u_short);
  14846. +         to = ((u_short *)to) + 1;
  14847. +         cnt -= 2;
  14848. +     }
  14849. +     if (cnt)
  14850. +         *(u_char *)to = ldb(a);
  14851. + }
  14852. + static __inline void
  14853. + copy_to_isa (const void *from, void *to, int cnt)
  14854. + {
  14855. +     int a = (int)to;
  14856. +     if (a & 1 && cnt) {
  14857. +         stb(a++, *(u_char *)from);
  14858. +         from = ((u_char *)from) + 1;
  14859. +         cnt--;
  14860. +     }
  14861. +     /* Maybe use Duff's device here... */
  14862. +     while (cnt > 1) {
  14863. +         stw(a, *(u_short *)from);
  14864. +         a += sizeof(u_short);
  14865. +         from = ((u_short *)from) + 1;
  14866. +         cnt -= 2;
  14867. +     }
  14868. +     if (cnt)
  14869. +         stb(a, *(u_char *)from);
  14870. + }
  14871. + static __inline void
  14872. + zero_isa (void *addr, int cnt)
  14873. + {
  14874. +     int a = (int)addr;
  14875. +     if (a & 1 && cnt) {
  14876. +         stb(a++, 0);
  14877. +         cnt--;
  14878. +     }
  14879. +     /* Maybe use Duff's device here... */
  14880. +     while (cnt > 1) {
  14881. +         stw(a, 0);
  14882. +         a += sizeof(u_short);
  14883. +         cnt -= 2;
  14884. +     }
  14885. +     if (cnt)
  14886. +         stb(a, 0);
  14887. + }
  14888. + /*
  14889. +  * These inlines convert shorts from/to isa (intel) byte order to host
  14890. +  * byte-order.  I know both are exactly equal, but I think it make code
  14891. +  * more readable to have separate names for them as they indeed have
  14892. +  * distinctive functionalities.
  14893. +  */
  14894. + static __inline u_short
  14895. + swap(u_short x)
  14896. + {
  14897. +     __asm("rolw #8,%0" : "=r" (x) : "0" (x));
  14898. +     return x;
  14899. + }
  14900. + static __inline u_short
  14901. + itohs(u_short x)
  14902. + {
  14903. + #if BYTE_ORDER == LITTLE_ENDIAN
  14904. +     return x;
  14905. + #else
  14906. +     return swap(x);
  14907. + #endif
  14908. + }
  14909. + static __inline u_short
  14910. + htois(u_short x)
  14911. + {
  14912. + #if BYTE_ORDER == LITTLE_ENDIAN
  14913. +     return x;
  14914. + #else
  14915. +     return swap(x);
  14916. + #endif
  14917. + }
  14918. + /*
  14919. +  * Given a physical address in the "hole",
  14920. +  * return a kernel virtual address.
  14921. +  */
  14922. + #define    ISA_HOLE_VADDR(p)  ((caddr_t)p)
  14923. + #endif
  14924. *** /dev/null
  14925. --- NetBSD/src/sys/arch/amiga/isa/isareg.h
  14926. ***************
  14927. *** 0 ****
  14928. --- 1,211 ----
  14929. + /*    $NetBSD: isareg.h,v 1.4 1994/10/27 04:17:49 cgd Exp $    */
  14930. + /*-
  14931. +  * Copyright (c) 1990 The Regents of the University of California.
  14932. +  * All rights reserved.
  14933. +  *
  14934. +  * This code is derived from software contributed to Berkeley by
  14935. +  * William Jolitz.
  14936. +  *
  14937. +  * Redistribution and use in source and binary forms, with or without
  14938. +  * modification, are permitted provided that the following conditions
  14939. +  * are met:
  14940. +  * 1. Redistributions of source code must retain the above copyright
  14941. +  *    notice, this list of conditions and the following disclaimer.
  14942. +  * 2. Redistributions in binary form must reproduce the above copyright
  14943. +  *    notice, this list of conditions and the following disclaimer in the
  14944. +  *    documentation and/or other materials provided with the distribution.
  14945. +  * 3. All advertising materials mentioning features or use of this software
  14946. +  *    must display the following acknowledgement:
  14947. +  *    This product includes software developed by the University of
  14948. +  *    California, Berkeley and its contributors.
  14949. +  * 4. Neither the name of the University nor the names of its contributors
  14950. +  *    may be used to endorse or promote products derived from this software
  14951. +  *    without specific prior written permission.
  14952. +  *
  14953. +  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  14954. +  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  14955. +  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  14956. +  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  14957. +  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  14958. +  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  14959. +  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  14960. +  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  14961. +  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  14962. +  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  14963. +  * SUCH DAMAGE.
  14964. +  *
  14965. +  *    @(#)isa.h    5.7 (Berkeley) 5/9/91
  14966. +  */
  14967. + /*
  14968. +  * ISA Bus conventions
  14969. +  */
  14970. + #ifndef LOCORE
  14971. + #include <sys/cdefs.h>
  14972. + unsigned char rtcin __P((int));
  14973. + void sysbeep __P((int, int));
  14974. + unsigned kbd_8042cmd __P((int));
  14975. + #endif /* !LOCORE */
  14976. + /*
  14977. +  * Input / Output Port Assignments
  14978. +  */
  14979. + #ifndef IO_BEGIN
  14980. + #define    IO_ISABEGIN    0x000        /* 0x000 - Beginning of I/O Registers */
  14981. +         /* CPU Board */
  14982. + #define    IO_DMA1        0x000        /* 8237A DMA Controller #1 */
  14983. + #define    IO_ICU1        0x020        /* 8259A Interrupt Controller #1 */
  14984. + #define    IO_PMP1        0x026        /* 82347 Power Management Peripheral */
  14985. + #define    IO_TIMER1    0x040        /* 8253 Timer #1 */
  14986. + #define    IO_TIMER2    0x048        /* 8253 Timer #2 (EISA only) */
  14987. + #define    IO_KBD        0x060        /* 8042 Keyboard */
  14988. + #define    IO_PPI        0x061        /* Programmable Peripheral Interface */
  14989. + #define    IO_RTC        0x070        /* RTC */
  14990. + #define    IO_NMI        IO_RTC        /* NMI Control */
  14991. + #define    IO_DMAPG    0x080        /* DMA Page Registers */
  14992. + #define    IO_ICU2        0x0A0        /* 8259A Interrupt Controller #2 */
  14993. + #define    IO_DMA2        0x0C0        /* 8237A DMA Controller #2 */
  14994. + #define    IO_NPX        0x0F0        /* Numeric Coprocessor */
  14995. +         /* Cards */
  14996. +                     /* 0x100 - 0x16F Open */
  14997. + #define    IO_WD2        0x170        /* Secondary Fixed Disk Controller */
  14998. + #define    IO_PMP2        0x178        /* 82347 Power Management Peripheral */
  14999. +                     /* 0x17A - 0x1EF Open */
  15000. + #define    IO_WD1        0x1f0        /* Primary Fixed Disk Controller */
  15001. + #define    IO_GAME        0x200        /* Game Controller */
  15002. +                     /* 0x208 - 0x237 Open */
  15003. + #define    IO_BMS2        0x238        /* secondary InPort Bus Mouse */
  15004. + #define    IO_BMS1        0x23c        /* primary InPort Bus Mouse */
  15005. +                     /* 0x240 - 0x277 Open */
  15006. + #define    IO_LPT2        0x278        /* Parallel Port #2 */
  15007. +                     /* 0x280 - 0x2E7 Open */
  15008. + #define    IO_COM4        0x2e8        /* COM4 i/o address */
  15009. +                     /* 0x2F0 - 0x2F7 Open */
  15010. + #define    IO_COM2        0x2f8        /* COM2 i/o address */
  15011. +                     /* 0x300 - 0x32F Open */
  15012. + #define    IO_BT0        0x330        /* bustek 742a default addr. */
  15013. + #define    IO_AHA0        0x330        /* adaptec 1542 default addr. */
  15014. + #define    IO_UHA0        0x330        /* ultrastore 14f default addr. */
  15015. + #define    IO_BT1          0x334        /* bustek 742a default addr. */
  15016. + #define    IO_AHA1         0x334        /* adaptec 1542 default addr. */
  15017. +                     /* 0x338 - 0x34F Open */
  15018. + #define    IO_WDS        0x350        /* WD7000 scsi */
  15019. +                     /* 0x354 - 0x36F Open */
  15020. + #define    IO_FD2        0x370        /* secondary base i/o address */
  15021. + #define    IO_LPT1        0x378        /* Parallel Port #1 */
  15022. +                     /* 0x380 - 0x3AF Open */
  15023. + #define    IO_MDA        0x3B0        /* Monochome Adapter */
  15024. + #define    IO_LPT3        0x3BC        /* Monochome Adapter Printer Port */
  15025. + #define    IO_VGA        0x3C0        /* E/VGA Ports */
  15026. + #define    IO_CGA        0x3D0        /* CGA Ports */
  15027. +                     /* 0x3E0 - 0x3E7 Open */
  15028. + #define    IO_COM3        0x3e8        /* COM3 i/o address */
  15029. + #define    IO_FD1        0x3f0        /* primary base i/o address */
  15030. + #define    IO_COM1        0x3f8        /* COM1 i/o address */
  15031. + #define    IO_ISAEND    0x3FF        /* - 0x3FF End of I/O Registers */
  15032. + #endif /* !IO_ISABEGIN */
  15033. + /*
  15034. +  * Input / Output Port Sizes - these are from several sources, and tend
  15035. +  * to be the larger of what was found, ie COM ports can be 4, but some
  15036. +  * boards do not fully decode the address, thus 8 ports are used.
  15037. +  */
  15038. + #ifndef    IO_ISASIZES
  15039. + #define    IO_ISASIZES
  15040. + #define    IO_COMSIZE    8    /* 8250, 16X50 com controllers (*/
  15041. + #define    IO_CGASIZE    16    /* CGA controllers */
  15042. + #define    IO_DMASIZE    16    /* 8237 DMA controllers */
  15043. + #define    IO_DPGSIZE    32    /* 74LS612 DMA page reisters */
  15044. + #define    IO_FDCSIZE    8    /* Nec765 floppy controllers */
  15045. + #define    IO_WDCSIZE    8    /* WD compatible disk controller */
  15046. + #define    IO_GAMSIZE    16    /* AT compatible game controller */
  15047. + #define    IO_ICUSIZE    16    /* 8259A interrupt controllers */
  15048. + #define    IO_KBDSIZE    16    /* 8042 Keyboard controllers */
  15049. + #define    IO_LPTSIZE    8    /* LPT controllers, some use onl */
  15050. + #define    IO_MDASIZE    16    /* Monochrome display controller */
  15051. + #define    IO_RTCSIZE    16    /* CMOS real time clock, NMI con */
  15052. + #define    IO_TMRSIZE    16    /* 8253 programmable timers */
  15053. + #define    IO_NPXSIZE    16    /* 80387/80487 NPX registers */
  15054. + #define    IO_VGASIZE    16    /* VGA controllers */
  15055. + #define    IO_PMPSIZE    2    /* 82347 Power Management Peripheral */
  15056. + #endif /* !IO_ISASIZES */
  15057. + /*
  15058. +  * Input / Output Memory Physical Addresses
  15059. +  */
  15060. + #ifndef    IOM_BEGIN
  15061. + #define    IOM_BEGIN    0x0a0000        /* Start of I/O Memory "hole" */
  15062. + #define    IOM_END        0x100000        /* End of I/O Memory "hole" */
  15063. + #define    IOM_SIZE    (IOM_END - IOM_BEGIN)
  15064. + #endif /* !IOM_BEGIN */
  15065. + /*
  15066. +  * RAM Physical Address Space (ignoring the above mentioned "hole")
  15067. +  */
  15068. + #ifndef    RAM_BEGIN
  15069. + #define    RAM_BEGIN    0x0000000    /* Start of RAM Memory */
  15070. + #define    RAM_END        0x1000000    /* End of RAM Memory */
  15071. + #define    RAM_SIZE    (RAM_END - RAM_BEGIN)
  15072. + #endif /* !RAM_BEGIN */
  15073. + /*
  15074. +  * Oddball Physical Memory Addresses
  15075. +  */
  15076. + #ifndef    COMPAQ_RAMRELOC
  15077. + #define    COMPAQ_RAMRELOC    0x80c00000    /* Compaq RAM relocation/diag */
  15078. + #define    COMPAQ_RAMSETUP    0x80c00002    /* Compaq RAM setup */
  15079. + #define    WEITEK_FPU    0xC0000000    /* WTL 2167 */
  15080. + #define    CYRIX_EMC    0xC0000000    /* Cyrix EMC */
  15081. + #endif /* !COMPAQ_RAMRELOC */
  15082. + /* stuff that used to be in pccons.c */
  15083. + #define    MONO_BASE    0x3B4
  15084. + #define    MONO_BUF    (KERNBASE + 0xB0000)
  15085. + #define    CGA_BASE    0x3D4
  15086. + #define    CGA_BUF        (KERNBASE + 0xB8000)
  15087. + #define    IOPHYSMEM    0xA0000
  15088. + /*
  15089. +  * size of dma bounce buffer in pages
  15090. +  * - currently 1 page per channel
  15091. +  */
  15092. + #ifndef DMA_BOUNCE
  15093. + #define    DMA_BOUNCE      8
  15094. + #endif
  15095. + #ifndef LOCORE
  15096. + extern vm_offset_t isaphysmem;
  15097. + #endif /* !LOCORE */
  15098. *** old-NetBSD/src/sys/arch/amiga/stand/videomode/videomode.c
  15099. --- NetBSD/src/sys/arch/amiga/stand/videomode/videomode.c
  15100. ***************
  15101. *** 1,6 ****
  15102. --- 1,7 ----
  15103.   /*    $NetBSD: videomode.c,v 1.3 1994/10/26 02:07:14 cgd Exp $    */
  15104.   
  15105.   #include <sys/types.h>
  15106. + #include <sys/device.h>
  15107.   #include <sys/stat.h>
  15108.   #include <sys/ioctl.h>
  15109.   #include "../../dev/grfioctl.h"
  15110. *** /dev/null
  15111. --- NetBSD/src/sys/arch/i386/conf/NETTAN
  15112. ***************
  15113. *** 0 ****
  15114. --- 1,173 ----
  15115. + #    $NetBSD: GENERIC,v 1.19 1995/07/24 03:33:12 mycroft Exp $
  15116. + #
  15117. + #    GENERIC -- everything that's currently supported
  15118. + #
  15119. + machine        i386        # architecture, used by config; REQUIRED
  15120. + options        I386_CPU    # CPU classes; at least one is REQUIRED
  15121. + options        I486_CPU
  15122. + options        I586_CPU
  15123. + options        MATH_EMULATE    # floating point emulation
  15124. + #options    DUMMY_NOPS    # speed hack; recommanded
  15125. + options        XSERVER,UCONSOLE
  15126. + options        INSECURE    # insecure; allow /dev/mem writing for X
  15127. + options        MACHINE_NONCONTIG
  15128. + maxusers    32        # estimated number of users
  15129. + options        TIMEZONE=0    # time zone to adjust RTC time by
  15130. + options        DST=0        # daylight savings time used by RTC
  15131. + options        SWAPPAGER    # paging; REQUIRED
  15132. + options        VNODEPAGER    # mmap() of files
  15133. + options        DEVPAGER    # mmap() of devices
  15134. + options        DDB        # in-kernel debugger
  15135. + #makeoptions    DEBUG="-g"    # compile full symbol table
  15136. + options        DIAGNOSTIC    # internally consistency checks
  15137. + options        KTRACE        # system call tracing, a la ktrace(1)
  15138. + options        SYSVMSG        # System V-like message queues
  15139. + options        SYSVSEM        # System V-like semaphores
  15140. + options        SYSVSHM        # System V-like memory sharing
  15141. + #options    SHMMAXPGS=1024    # 1024 pages is the default
  15142. + options        COMPAT_NOMID    # compatibility with 386BSD, BSDI, NetBSD 0.8,
  15143. + options        COMPAT_09    # NetBSD 0.9,
  15144. + options        COMPAT_10    # NetBSD 1.0,
  15145. + options        COMPAT_43    # and 4.3BSD
  15146. + options        TCP_COMPAT_42    # TCP bug compatibility with 4.2BSD
  15147. + options        COMPAT_SVR4    # binary compatibility with SVR4
  15148. + options        COMPAT_IBCS2    # binary compatibility with SCO and ISC
  15149. + options        COMPAT_LINUX    # binary compatibility with Linux
  15150. + options        USER_LDT    # user-settable LDT; used by WINE
  15151. + options        LKM        # loadable kernel modules
  15152. + options        FFS        # UFS
  15153. + options        QUOTA        # UFS quotas
  15154. + options        LFS        # log-structured file system
  15155. + options        MFS        # memory file system
  15156. + options        NFSCLIENT    # Network File System client
  15157. + options        NFSSERVER    # Network File System server
  15158. + options        CD9660        # ISO 9660 + Rock Ridge file system
  15159. + options        MSDOSFS        # MS-DOS file system
  15160. + options        FDESC        # /dev/fd
  15161. + options        FIFO        # FIFOs; RECOMMENDED
  15162. + options        KERNFS        # /kern
  15163. + options        NULLFS        # loopback file system
  15164. + options        PORTAL        # ?
  15165. + options        PROCFS        # /proc
  15166. + options        UMAPFS        # NULLFS + uid and gid remapping
  15167. + options        UNION        # union file system
  15168. + #options    GATEWAY        # packet forwarding
  15169. + options        INET        # IP + ICMP + TCP + UDP
  15170. + options        NS        # XNS
  15171. + options        ISO,TPIP    # OSI
  15172. + options        EON        # OSI tunneling over IP
  15173. + options        CCITT,LLC,HDLC    # X.25
  15174. + config        netbsd    swap generic
  15175. + options        GENERIC
  15176. + isa0    at root
  15177. + pci0    at root
  15178. + npx0    at isa? port 0xf0 irq 13    # math coprocessor
  15179. + pc0    at isa? port 0x60 irq 1        # generic PC console device
  15180. + #vt0    at isa? port 0x60 irq 1
  15181. + com0    at isa? port 0x3f8 irq 4    # standard PC serial ports
  15182. + com1    at isa? port 0x2f8 irq 3
  15183. + com2    at isa? port 0x3e8 irq 5
  15184. + #com3    at isa? port 0x2e8 irq 9
  15185. + #ast0    at isa? port 0x1a0 irq 5    # AST 4-port serial cards
  15186. + #com*    at ast? slave ? flags 1
  15187. + #boca0    at isa? port 0x100 irq 5    # BOCA 8-port serial cards
  15188. + #com*    at boca? slave ?
  15189. + #rtfps0    at isa? port 0x1230 irq 10    # RT 4-port serial cards
  15190. + #com*    at rtfps? slave ?
  15191. + #cy0    at isa? ...
  15192. + lpt0    at isa? port 0x378 irq 7    # standard PC parallel ports
  15193. + lpt1    at isa? port 0x278
  15194. + lpt2    at isa? port 0x3bc
  15195. + lms0    at isa? port 0x23c irq 5    # Logitech bus mouse
  15196. + lms1    at isa? port 0x238 irq 5
  15197. + mms0    at isa? port 0x23c irq 5    # Microsoft InPort mouse
  15198. + mms1    at isa? port 0x238 irq 5
  15199. + #pms0    at isa? port 0x60 irq 12    # PS/2 auxiliary port mouse
  15200. + aha0    at isa? port 0x330 irq ? drq ?    # Adaptec 154[02] SCSI controllers
  15201. + aha1    at isa? port 0x334 irq ? drq ?    # Adaptec 154[02] SCSI controllers
  15202. + scsibus* at aha?
  15203. + ahb0    at isa? port ? irq ?        # Adaptec 174[024] SCSI controllers
  15204. + scsibus* at ahb?
  15205. + aic0    at isa? port 0x340 irq 12    # Adaptec 152[02] SCSI controllers
  15206. + scsibus* at aic?
  15207. + bt0    at isa? port 0x330 irq ? drq ?    # BusLogic [57]4X SCSI controllers
  15208. + bt1    at isa? port 0x334 irq ? drq ?    # BusLogic [57]4X SCSI controllers
  15209. + bt2    at isa? port ? irq ?
  15210. + scsibus* at bt?
  15211. + ncr*    at pci? bus ? dev ?        # NCR 538XX SCSI controllers
  15212. + scsibus* at ncr?
  15213. + sea0    at isa? iomem 0xc8000 irq 5
  15214. + scsibus* at sea?
  15215. + uha0    at isa? port 0x330 irq ? drq ?    # UltraStor [13]4f SCSI controllers
  15216. + uha1    at isa? port 0x334 irq ? drq ?    # UltraStor [13]4f SCSI controllers
  15217. + uha2    at isa? port ? irq ?        # UltraStor 24f SCSI controllers
  15218. + scsibus* at uha?
  15219. + sd*    at scsibus? target ? lun ?    # SCSI disk drives
  15220. + st*    at scsibus? target ? lun ?    # SCSI tape drives
  15221. + cd*    at scsibus? target ? lun ?    # SCSI CD-ROM drives
  15222. + ch*    at scsibus? target ? lun ?    # SCSI autochangers
  15223. + fdc0    at isa? port 0x3f0 irq 6 drq 2    # standard PC floppy controllers
  15224. + #fdc1    at isa? port 0x370 irq ? drq ?
  15225. + fd*    at fdc? drive ?
  15226. + mcd0    at isa? port 0x300 irq 10    # Mitsumi CD-ROM drives
  15227. + wdc0    at isa? port 0x1f0 irq 14    # ST506, ESDI, and IDE controllers
  15228. + #wdc1    at isa? port 0x170 irq ?
  15229. + wd*    at wdc? drive ?
  15230. + wt0    at isa? port 0x300 irq 5 drq 1    # Archive and Wangtek QIC tape drives
  15231. + ed0    at isa? port 0x280 iomem 0xd0000 irq 9    # WD/SMC, 3C503, and NE[12]000
  15232. + ed1    at isa? port 0x250 iomem 0xd8000 irq 9    #   ethernet cards
  15233. + ed2    at isa? port 0x300 iomem 0xcc000 irq 10
  15234. + #eg0    at isa? ...                # 3C505 ethernet cards
  15235. + el0    at isa? port 0x300 irq 9        # 3C501 ethernet cards
  15236. + ep0    at isa? port ? irq ?            # 3C509 ethernet cards
  15237. + ie0    at isa? port 0x360 iomem 0xd0000 irq 7    # StarLAN & 3C507 ethernet cards
  15238. + #le0    at isa? port 0x320 irq 10 drq 7        # IsoLan, NE2100, and DEPCA
  15239. + de*    at pci? bus ? dev ?
  15240. + pss0    at isa? port 0x220 irq 7 drq 6  # Personal Sound System
  15241. + sp0    at pss0 port 0x530 irq 10 drq 0    #     sound port driver
  15242. + sb0    at isa? port 0x220 irq 7 drq 1    # SoundBlaster
  15243. + wss0    at isa? port 0x530 irq 10 drq 0    # Windows Sound System
  15244. + pas0    at isa? port 0x220 irq 7 drq 1    # ProAudio Spectrum
  15245. + gus0    at isa? port 0x220 irq 7 drq 1 flags 6 # Gravis Ultra Sound (flags is record drq for full-duplex)
  15246. + #spkr0    at isa? ...
  15247. + pseudo-device    loop    1        # network loopback
  15248. + pseudo-device    bpfilter 8        # packet filter
  15249. + pseudo-device    sl    2        # CSLIP
  15250. + pseudo-device    ppp    2        # PPP
  15251. + pseudo-device    tun    2        # network tunneling over tty
  15252. + pseudo-device    pty    64        # pseudo-terminals
  15253. + pseudo-device    tb    1        # tablet line discipline
  15254. + pseudo-device    vnd    4        # paging to files
  15255. *** old-NetBSD/src/sys/dev/cons.h
  15256. --- NetBSD/src/sys/dev/cons.h
  15257. ***************
  15258. *** 80,85 ****
  15259. --- 80,86 ----
  15260.   int    cnselect __P((dev_t, int, struct proc *));
  15261.   int    cngetc __P((void));
  15262.   int    cnputc __P((int));
  15263. + void    nullcnpollc __P((int));
  15264.   
  15265.   /* console-specific types */
  15266.   #define    dev_type_cnprobe(n)    void n __P((struct consdev *))
  15267. *** old-NetBSD/src/sys/dev/ic/dp8390reg.h
  15268. --- NetBSD/src/sys/dev/ic/dp8390reg.h
  15269. ***************
  15270. *** 530,536 ****
  15271.    * was received.
  15272.    */
  15273.   struct ed_ring    {
  15274. ! #if BYTE_ORDER == BIG_ENDIAN
  15275.       u_char    next_packet;        /* pointer to next packet */
  15276.       u_char    rsr;            /* receiver status */
  15277.   #else
  15278. --- 530,536 ----
  15279.    * was received.
  15280.    */
  15281.   struct ed_ring    {
  15282. ! #if ED_BYTE_ORDER == BIG_ENDIAN
  15283.       u_char    next_packet;        /* pointer to next packet */
  15284.       u_char    rsr;            /* receiver status */
  15285.   #else
  15286. *** old-NetBSD/src/sys/dev/isa/com.c
  15287. --- NetBSD/src/sys/dev/isa/com.c
  15288. ***************
  15289. *** 100,105 ****
  15290. --- 100,106 ----
  15291.   void compoll __P((void *));
  15292.   int comparam __P((struct tty *, struct termios *));
  15293.   void comstart __P((struct tty *));
  15294. + int comhwiflow __P((struct tty *, int));
  15295.   
  15296.   struct cfdriver comcd = {
  15297.       NULL, "com", comprobe, comattach, DV_TTY, sizeof(struct com_softc)
  15298. ***************
  15299. *** 282,287 ****
  15300. --- 283,289 ----
  15301.   
  15302.       tp->t_oproc = comstart;
  15303.       tp->t_param = comparam;
  15304. +     tp->t_hwiflow = comhwiflow;
  15305.       tp->t_dev = dev;
  15306.       if ((tp->t_state & TS_ISOPEN) == 0) {
  15307.           tp->t_state |= TS_WOPEN;
  15308. ***************
  15309. *** 879,884 ****
  15310. --- 881,915 ----
  15311.           if (inb(iobase + com_iir) & IIR_NOPEND)
  15312.               return (1);
  15313.       }
  15314. + }
  15315. + int
  15316. + comhwiflow(tp, flag)
  15317. +         struct tty *tp;
  15318. +         int flag;
  15319. + {
  15320. +     struct com_softc *sc = comcd.cd_devs[COMUNIT(tp->t_dev)];
  15321. +     int iobase = sc->sc_iobase;
  15322. +     int s;
  15323. +     static unsigned int startusec, startticks;
  15324. +     extern int ticks;
  15325. +     int elapsed;
  15326. +     s = spltty();
  15327. +         if (flag) {
  15328. +         sc->sc_mcr &= ~MCR_RTS;
  15329. +         startusec = clkread();
  15330. +         startticks = ticks;
  15331. +     } else {
  15332. +             elapsed = clkread() - startusec + (ticks - startticks) * 10000;
  15333. +             sc->sc_mcr |= MCR_RTS;
  15334. +     }
  15335. +     outb(iobase + com_mcr, sc->sc_mcr);
  15336. +     splx(s);
  15337. +     if (!flag)
  15338. +         printf ("%s: comhwiflow %d ms\n", sc->sc_dev.dv_xname,
  15339. +             elapsed / 1000);
  15340. +         return 1;
  15341.   }
  15342.   
  15343.   /*
  15344. *** old-NetBSD/src/sys/dev/isa/if_ed.c
  15345. --- NetBSD/src/sys/dev/isa/if_ed.c
  15346. ***************
  15347. *** 518,524 ****
  15348.       (void) inb(0x84);
  15349.   
  15350.       /* Now zero memory and verify that it is clear. */
  15351. !     bzero(sc->mem_start, memsize);
  15352.   
  15353.       for (i = 0; i < memsize; ++i)
  15354.           if (sc->mem_start[i]) {
  15355. --- 518,524 ----
  15356.       (void) inb(0x84);
  15357.   
  15358.       /* Now zero memory and verify that it is clear. */
  15359. !     isa_zero(sc->mem_start, memsize);
  15360.   
  15361.       for (i = 0; i < memsize; ++i)
  15362.           if (sc->mem_start[i]) {
  15363. ***************
  15364. *** 784,790 ****
  15365.       outb(sc->asic_addr + ED_3COM_VPTR0, 0x00);
  15366.   
  15367.       /* Zero memory and verify that it is clear. */
  15368. !     bzero(sc->mem_start, memsize);
  15369.   
  15370.       for (i = 0; i < memsize; ++i)
  15371.           if (sc->mem_start[i]) {
  15372. --- 784,790 ----
  15373.       outb(sc->asic_addr + ED_3COM_VPTR0, 0x00);
  15374.   
  15375.       /* Zero memory and verify that it is clear. */
  15376. !     isa_zero(sc->mem_start, memsize);
  15377.   
  15378.       for (i = 0; i < memsize; ++i)
  15379.           if (sc->mem_start[i]) {
  15380. ***************
  15381. *** 1401,1407 ****
  15382.           }
  15383.   
  15384.           for (m = m0; m != 0; m = m->m_next) {
  15385. !             bcopy(mtod(m, caddr_t), buffer, m->m_len);
  15386.               buffer += m->m_len;
  15387.           }
  15388.           len = m0->m_pkthdr.len;
  15389. --- 1401,1407 ----
  15390.           }
  15391.   
  15392.           for (m = m0; m != 0; m = m->m_next) {
  15393. !             copy_to_isa(mtod(m, caddr_t), buffer, m->m_len);
  15394.               buffer += m->m_len;
  15395.           }
  15396.           len = m0->m_pkthdr.len;
  15397. ***************
  15398. *** 1488,1494 ****
  15399.           else
  15400.               ed_pio_readmem(sc, (long)packet_ptr,
  15401.                   (caddr_t) &packet_hdr, sizeof(packet_hdr));
  15402. !         len = packet_hdr.count;
  15403.   
  15404.           /*
  15405.            * Try do deal with old, buggy chips that sometimes duplicate
  15406. --- 1488,1494 ----
  15407.           else
  15408.               ed_pio_readmem(sc, (long)packet_ptr,
  15409.                   (caddr_t) &packet_hdr, sizeof(packet_hdr));
  15410. !         len = itohs(packet_hdr.count);
  15411.   
  15412.           /*
  15413.            * Try do deal with old, buggy chips that sometimes duplicate
  15414. ***************
  15415. *** 1508,1518 ****
  15416.               --nlen;
  15417.           len = (len & ED_PAGE_MASK) | (nlen << ED_PAGE_SHIFT);
  15418.   #ifdef DIAGNOSTIC
  15419. !         if (len != packet_hdr.count) {
  15420.               printf("%s: length does not match next packet pointer\n",
  15421.                   sc->sc_dev.dv_xname);
  15422.               printf("%s: len %04x nlen %04x start %02x first %02x curr %02x next %02x stop %02x\n",
  15423. !                 sc->sc_dev.dv_xname, packet_hdr.count, len,
  15424.                   sc->rec_page_start, sc->next_packet, current,
  15425.                   packet_hdr.next_packet, sc->rec_page_stop);
  15426.           }
  15427. --- 1508,1518 ----
  15428.               --nlen;
  15429.           len = (len & ED_PAGE_MASK) | (nlen << ED_PAGE_SHIFT);
  15430.   #ifdef DIAGNOSTIC
  15431. !         if (len != itohs(packet_hdr.count)) {
  15432.               printf("%s: length does not match next packet pointer\n",
  15433.                   sc->sc_dev.dv_xname);
  15434.               printf("%s: len %04x nlen %04x start %02x first %02x curr %02x next %02x stop %02x\n",
  15435. !                 sc->sc_dev.dv_xname, itohs(packet_hdr.count), len,
  15436.                   sc->rec_page_start, sc->next_packet, current,
  15437.                   packet_hdr.next_packet, sc->rec_page_stop);
  15438.           }
  15439. ***************
  15440. *** 2119,2125 ****
  15441.   
  15442.           /* Copy amount up to end of NIC memory. */
  15443.           if (sc->mem_shared)
  15444. !             bcopy(src, dst, tmp_amount);
  15445.           else
  15446.               ed_pio_readmem(sc, (long)src, dst, tmp_amount);
  15447.   
  15448. --- 2119,2125 ----
  15449.   
  15450.           /* Copy amount up to end of NIC memory. */
  15451.           if (sc->mem_shared)
  15452. !             copy_from_isa(src, dst, tmp_amount);
  15453.           else
  15454.               ed_pio_readmem(sc, (long)src, dst, tmp_amount);
  15455.   
  15456. ***************
  15457. *** 2129,2135 ****
  15458.       }
  15459.   
  15460.       if (sc->mem_shared)
  15461. !         bcopy(src, dst, amount);
  15462.       else
  15463.           ed_pio_readmem(sc, (long)src, dst, amount);
  15464.   
  15465. --- 2129,2135 ----
  15466.       }
  15467.   
  15468.       if (sc->mem_shared)
  15469. !         copy_from_isa(src, dst, amount);
  15470.       else
  15471.           ed_pio_readmem(sc, (long)src, dst, amount);
  15472.   
  15473. *** old-NetBSD/src/sys/kern/exec_conf.c
  15474. --- NetBSD/src/sys/kern/exec_conf.c
  15475. ***************
  15476. *** 37,42 ****
  15477. --- 37,46 ----
  15478.   #define EXEC_ECOFF
  15479.   #endif
  15480.   
  15481. + #if defined(COMPAT_NCR32)
  15482. + #define EXEC_COFF
  15483. + #endif
  15484.   #if defined(COMPAT_SVR4) || defined(COMPAT_LINUX)
  15485.   #define EXEC_ELF
  15486.   #endif
  15487. ***************
  15488. *** 56,61 ****
  15489. --- 60,69 ----
  15490.   #include <sys/exec_ecoff.h>
  15491.   #endif
  15492.   
  15493. + #ifdef EXEC_COFF
  15494. + #include <sys/exec_coff.h>
  15495. + #endif
  15496.   #ifdef EXEC_ELF
  15497.   #include <sys/exec_elf.h>
  15498.   #endif
  15499. ***************
  15500. *** 88,93 ****
  15501. --- 96,104 ----
  15502.   #endif
  15503.   #ifdef EXEC_ECOFF
  15504.       { ECOFF_HDR_SIZE, exec_ecoff_makecmds, },    /* ecoff binaries */
  15505. + #endif
  15506. + #ifdef EXEC_COFF
  15507. +     { COFF_HDR_SIZE, exec_coff_makecmds, },    /* coff binaries */
  15508.   #endif
  15509.   #ifdef EXEC_ELF
  15510.       { ELF_HDR_SIZE, exec_elf_makecmds, },    /* elf binaries */
  15511. *** old-NetBSD/src/sys/kern/kern_lkm.c
  15512. --- NetBSD/src/sys/kern/kern_lkm.c
  15513. ***************
  15514. *** 81,86 ****
  15515. --- 81,90 ----
  15516.   static struct lkm_table    lkmods[MAXLKMS];    /* table of loaded modules */
  15517.   static struct lkm_table    *curp;            /* global for in-progress ops */
  15518.   
  15519. + #ifdef DEBUG
  15520. + int lkm_debug = 0;
  15521. + #endif
  15522.   /*ARGSUSED*/
  15523.   int
  15524.   lkmopen(dev, flag, devtype, p)
  15525. ***************
  15526. *** 148,154 ****
  15527.   
  15528.       if (!(lkm_v & LKM_ALLOC)) {
  15529.   #ifdef DEBUG
  15530. !         printf("LKM: close before open!\n");
  15531.   #endif    /* DEBUG */
  15532.           return (EBADF);
  15533.       }
  15534. --- 152,159 ----
  15535.   
  15536.       if (!(lkm_v & LKM_ALLOC)) {
  15537.   #ifdef DEBUG
  15538. !             if (lkm_debug)
  15539. !                 printf("LKM: close before open!\n");
  15540.   #endif    /* DEBUG */
  15541.           return (EBADF);
  15542.       }
  15543. ***************
  15544. *** 220,228 ****
  15545.           resrvp->addr = curp->area; /* ret kernel addr */
  15546.   
  15547.   #ifdef DEBUG
  15548. !         printf("LKM: LMRESERV (actual   = 0x%08x)\n", curp->area);
  15549. !         printf("LKM: LMRESERV (adjusted = 0x%08x)\n",
  15550. !             trunc_page(curp->area));
  15551.   #endif    /* DEBUG */
  15552.           lkm_state = LKMS_RESERVED;
  15553.           break;
  15554. --- 225,235 ----
  15555.           resrvp->addr = curp->area; /* ret kernel addr */
  15556.   
  15557.   #ifdef DEBUG
  15558. !         if (lkm_debug) {
  15559. !                 printf("LKM: LMRESERV (actual   = 0x%08x)\n", curp->area);
  15560. !                 printf("LKM: LMRESERV (adjusted = 0x%08x)\n",
  15561. !                    trunc_page(curp->area));
  15562. !         }
  15563.   #endif    /* DEBUG */
  15564.           lkm_state = LKMS_RESERVED;
  15565.           break;
  15566. ***************
  15567. *** 248,260 ****
  15568.           if ((curp->offset + i) < curp->size) {
  15569.               lkm_state = LKMS_LOADING;
  15570.   #ifdef DEBUG
  15571. !             printf("LKM: LMLOADBUF (loading @ %d of %d, i = %d)\n",
  15572. !             curp->offset, curp->size, i);
  15573.   #endif    /* DEBUG */
  15574.           } else {
  15575.               lkm_state = LKMS_LOADED;
  15576.   #ifdef DEBUG
  15577. !             printf("LKM: LMLOADBUF (loaded)\n");
  15578.   #endif    /* DEBUG */
  15579.           }
  15580.           curp->offset += i;
  15581. --- 255,269 ----
  15582.           if ((curp->offset + i) < curp->size) {
  15583.               lkm_state = LKMS_LOADING;
  15584.   #ifdef DEBUG
  15585. !             if (lkm_debug)
  15586. !                     printf("LKM: LMLOADBUF (loading @ %d of %d, i = %d)\n",
  15587. !                            curp->offset, curp->size, i);
  15588.   #endif    /* DEBUG */
  15589.           } else {
  15590.               lkm_state = LKMS_LOADED;
  15591.   #ifdef DEBUG
  15592. !             if (lkm_debug)
  15593. !                     printf("LKM: LMLOADBUF (loaded)\n");
  15594.   #endif    /* DEBUG */
  15595.           }
  15596.           curp->offset += i;
  15597. ***************
  15598. *** 266,272 ****
  15599.   
  15600.           lkmunreserve();    /* coerce state to LKM_IDLE */
  15601.   #ifdef DEBUG
  15602. !         printf("LKM: LMUNRESERV\n");
  15603.   #endif    /* DEBUG */
  15604.           break;
  15605.   
  15606. --- 275,282 ----
  15607.   
  15608.           lkmunreserve();    /* coerce state to LKM_IDLE */
  15609.   #ifdef DEBUG
  15610. !             if (lkm_debug)
  15611. !                 printf("LKM: LMUNRESERV\n");
  15612.   #endif    /* DEBUG */
  15613.           break;
  15614.   
  15615. ***************
  15616. *** 285,291 ****
  15617.           default:
  15618.   
  15619.   #ifdef DEBUG
  15620. !             printf("lkm_state is %02x\n", lkm_state);
  15621.   #endif    /* DEBUG */
  15622.               return ENXIO;
  15623.           }
  15624. --- 295,302 ----
  15625.           default:
  15626.   
  15627.   #ifdef DEBUG
  15628. !                 if (lkm_debug)
  15629. !                     printf("lkm_state is %02x\n", lkm_state);
  15630.   #endif    /* DEBUG */
  15631.               return ENXIO;
  15632.           }
  15633. ***************
  15634. *** 306,312 ****
  15635.   
  15636.           curp->used = 1;
  15637.   #ifdef DEBUG
  15638. !         printf("LKM: LMREADY\n");
  15639.   #endif    /* DEBUG */
  15640.           lkm_state = LKMS_IDLE;
  15641.           break;
  15642. --- 317,324 ----
  15643.   
  15644.           curp->used = 1;
  15645.   #ifdef DEBUG
  15646. !             if (lkm_debug)
  15647. !                 printf("LKM: LMREADY\n");
  15648.   #endif    /* DEBUG */
  15649.           lkm_state = LKMS_IDLE;
  15650.           break;
  15651. *** old-NetBSD/src/sys/kern/tty.c
  15652. --- NetBSD/src/sys/kern/tty.c
  15653. ***************
  15654. *** 1045,1058 ****
  15655.        */
  15656.       if (total >= TTYHOG / 2 &&
  15657.           !ISSET(tp->t_state, TS_TBLOCK) &&
  15658. !         !ISSET(tp->t_lflag, ICANON) || tp->t_canq.c_cc > 0) {
  15659.           if (ISSET(tp->t_iflag, IXOFF) &&
  15660.               tp->t_cc[VSTOP] != _POSIX_VDISABLE &&
  15661.               putc(tp->t_cc[VSTOP], &tp->t_outq) == 0) {
  15662. !             SET(tp->t_state, TS_TBLOCK);
  15663.               ttstart(tp);
  15664.           }
  15665. !         /* Try to block remote output via hardware flow control. */
  15666.           if (ISSET(tp->t_cflag, CHWFLOW) && tp->t_hwiflow &&
  15667.               (*tp->t_hwiflow)(tp, 1) != 0)
  15668.               SET(tp->t_state, TS_TBLOCK);
  15669. --- 1045,1058 ----
  15670.        */
  15671.       if (total >= TTYHOG / 2 &&
  15672.           !ISSET(tp->t_state, TS_TBLOCK) &&
  15673. !         (!ISSET(tp->t_lflag, ICANON) || tp->t_canq.c_cc > 0)) {
  15674.           if (ISSET(tp->t_iflag, IXOFF) &&
  15675.               tp->t_cc[VSTOP] != _POSIX_VDISABLE &&
  15676.               putc(tp->t_cc[VSTOP], &tp->t_outq) == 0) {
  15677. !                 SET(tp->t_state, TS_TBLOCK);
  15678.               ttstart(tp);
  15679.           }
  15680. !         /* Try to block remote output via hardware flow control */
  15681.           if (ISSET(tp->t_cflag, CHWFLOW) && tp->t_hwiflow &&
  15682.               (*tp->t_hwiflow)(tp, 1) != 0)
  15683.               SET(tp->t_state, TS_TBLOCK);
  15684. ***************
  15685. *** 1379,1388 ****
  15686.               CLR(tp->t_state, TS_TBLOCK);
  15687.               ttstart(tp);
  15688.           }
  15689. !         /* Try to unblock remote output via hardware flow control. */
  15690.           if (ISSET(tp->t_cflag, CHWFLOW) && tp->t_hwiflow &&
  15691.               (*tp->t_hwiflow)(tp, 0) != 0)
  15692. !             CLR(tp->t_state, TS_TBLOCK);
  15693.       }
  15694.       splx(s);
  15695.       return (error);
  15696. --- 1379,1388 ----
  15697.               CLR(tp->t_state, TS_TBLOCK);
  15698.               ttstart(tp);
  15699.           }
  15700. !         /* Try to unblock remote output via hardware flow control */
  15701.           if (ISSET(tp->t_cflag, CHWFLOW) && tp->t_hwiflow &&
  15702.               (*tp->t_hwiflow)(tp, 0) != 0)
  15703. !             tp->t_state &= ~TS_TBLOCK;
  15704.       }
  15705.       splx(s);
  15706.       return (error);
  15707. *** old-NetBSD/src/sys/lib/libkern/arch/m68k/Makefile.inc
  15708. --- NetBSD/src/sys/lib/libkern/arch/m68k/Makefile.inc
  15709. ***************
  15710. *** 2,5 ****
  15711.   
  15712.   SRCS+=    __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \
  15713.       bcmp.S bzero.S ffs.S strcat.c strcmp.S strcpy.S strlen.S strncmp.S \
  15714. !     strncpy.S htonl.S htons.S ntohl.S ntohs.S scanc.S skpc.S locc.S
  15715. --- 2,6 ----
  15716.   
  15717.   SRCS+=    __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \
  15718.       bcmp.S bzero.S ffs.S strcat.c strcmp.S strcpy.S strlen.S strncmp.S \
  15719. !     strncpy.S htonl.S htons.S ntohl.S ntohs.S scanc.S skpc.S locc.S \
  15720. !     memcpy.S
  15721. *** /dev/null
  15722. --- NetBSD/src/sys/lib/libkern/arch/m68k/bcopy.S
  15723. ***************
  15724. *** 0 ****
  15725. --- 1,132 ----
  15726. + /*-
  15727. +  * Copyright (c) 1990 The Regents of the University of California.
  15728. +  * All rights reserved.
  15729. +  *
  15730. +  * This code is derived from software contributed to Berkeley by
  15731. +  * the Systems Programming Group of the University of Utah Computer
  15732. +  * Science Department.
  15733. +  *
  15734. +  * Redistribution and use in source and binary forms, with or without
  15735. +  * modification, are permitted provided that the following conditions
  15736. +  * are met:
  15737. +  * 1. Redistributions of source code must retain the above copyright
  15738. +  *    notice, this list of conditions and the following disclaimer.
  15739. +  * 2. Redistributions in binary form must reproduce the above copyright
  15740. +  *    notice, this list of conditions and the following disclaimer in the
  15741. +  *    documentation and/or other materials provided with the distribution.
  15742. +  * 3. All advertising materials mentioning features or use of this software
  15743. +  *    must display the following acknowledgement:
  15744. +  *    This product includes software developed by the University of
  15745. +  *    California, Berkeley and its contributors.
  15746. +  * 4. Neither the name of the University nor the names of its contributors
  15747. +  *    may be used to endorse or promote products derived from this software
  15748. +  *    without specific prior written permission.
  15749. +  *
  15750. +  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  15751. +  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15752. +  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  15753. +  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  15754. +  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  15755. +  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  15756. +  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  15757. +  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  15758. +  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  15759. +  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  15760. +  * SUCH DAMAGE.
  15761. +  */
  15762. + #if defined(LIBC_SCCS) && !defined(lint)
  15763. +     .text
  15764. +     /*.asciz "from: @(#)bcopy.s    5.1 (Berkeley) 5/12/90"*/
  15765. +     .asciz "$Id$"
  15766. + #endif /* LIBC_SCCS and not lint */
  15767. + #include "DEFS.h"
  15768. + /*
  15769. +  * This is probably not the best we can do, but it is still 2-10 times
  15770. +  * faster than the C version in the portable gen directory.
  15771. +  *
  15772. +  * Things that might help:
  15773. +  *    - unroll the longword copy loop (might not be good for a 68020)
  15774. +  *    - longword align when possible (only on the 68020)
  15775. +  *    - use nested DBcc instructions or use one and limit size to 64K
  15776. +  */
  15777. + #ifdef MEMCOPY
  15778. + ENTRY(memcpy)
  15779. + #else
  15780. + #ifdef MEMMOVE
  15781. + ENTRY(memmove)
  15782. + #else
  15783. + ENTRY(bcopy)
  15784. + #endif
  15785. + #endif
  15786. +     movl    sp@(12),d1        | check count
  15787. +     beq    bcdone            | == 0, don't do anything
  15788. + #if defined(MEMCOPY) || defined(MEMMOVE)
  15789. +     movl    sp@(4),a1        | dest address
  15790. +     movl    sp@(8),a0        | src address
  15791. + #else
  15792. +     movl    sp@(4),a0        | src address
  15793. +     movl    sp@(8),a1        | dest address
  15794. + #endif
  15795. +     cmpl    a1,a0            | src after dest?
  15796. +     blt    bcback            | yes, must copy backwards
  15797. +     movl    a0,d0
  15798. +     btst    #0,d0            | src address odd?
  15799. +     beq    bcfeven            | no, skip alignment
  15800. +     movb    a0@+,a1@+        | yes, copy a byte
  15801. +     subql    #1,d1            | adjust count
  15802. +     beq    bcdone            | count 0, all done 
  15803. + bcfeven:
  15804. +     movl    a1,d0
  15805. +     btst    #0,d0            | dest address odd?
  15806. +     bne    bcfbloop        | yes, no hope for alignment, copy bytes
  15807. +     movl    d1,d0            | no, both even
  15808. +     lsrl    #2,d0            | convert count to longword count
  15809. +     beq    bcfbloop        | count 0, skip longword loop
  15810. + bcflloop:
  15811. +     movl    a0@+,a1@+        | copy a longword
  15812. +     subql    #1,d0            | adjust count
  15813. +     bne    bcflloop        | still more, keep copying
  15814. +     andl    #3,d1            | what remains
  15815. +     beq    bcdone            | nothing, all done
  15816. + bcfbloop:
  15817. +     movb    a0@+,a1@+        | copy a byte
  15818. +     subql    #1,d1            | adjust count
  15819. +     bne    bcfbloop        | still more, keep going
  15820. + bcdone:
  15821. + #if defined(MEMCOPY) || defined(MEMMOVE)
  15822. +     movl    sp@(4),d0        | dest address
  15823. + #endif
  15824. +     rts
  15825. + bcback:
  15826. +     addl    d1,a0            | src pointer to end
  15827. +     addl    d1,a1            | dest pointer to end
  15828. +     movl    a0,d0
  15829. +     btst    #0,d0            | src address odd?
  15830. +     beq    bcbeven            | no, skip alignment
  15831. +     movb    a0@-,a1@-        | yes, copy a byte
  15832. +     subql    #1,d1            | adjust count
  15833. +     beq    bcdone            | count 0, all done 
  15834. + bcbeven:
  15835. +     movl    a1,d0
  15836. +     btst    #0,d0            | dest address odd?
  15837. +     bne    bcbbloop        | yes, no hope for alignment, copy bytes
  15838. +     movl    d1,d0            | no, both even
  15839. +     lsrl    #2,d0            | convert count to longword count
  15840. +     beq    bcbbloop        | count 0, skip longword loop
  15841. + bcblloop:
  15842. +     movl    a0@-,a1@-        | copy a longword
  15843. +     subql    #1,d0            | adjust count
  15844. +     bne    bcblloop        | still more, keep copying
  15845. +     andl    #3,d1            | what remains
  15846. +     beq    bcdone            | nothing, all done
  15847. + bcbbloop:
  15848. +     movb    a0@-,a1@-        | copy a byte
  15849. +     subql    #1,d1            | adjust count
  15850. +     bne    bcbbloop        | still more, keep going
  15851. + #if defined(MEMCOPY) || defined(MEMMOVE)
  15852. +     movl    sp@(4),d0        | dest address
  15853. + #endif
  15854. +     rts
  15855. *** /dev/null
  15856. --- NetBSD/src/sys/lib/libkern/arch/m68k/memcpy.S
  15857. ***************
  15858. *** 0 ****
  15859. --- 1,2 ----
  15860. + #define MEMCOPY
  15861. + #include "bcopy.S"
  15862. *** old-NetBSD/src/sys/scsi/scsi_ioctl.c
  15863. --- NetBSD/src/sys/scsi/scsi_ioctl.c
  15864. ***************
  15865. *** 166,172 ****
  15866.           screq->retsts = SCCMD_UNKNOWN;
  15867.           break;
  15868.       }
  15869. !     biodone(bp);     /* we're waiting on it in scsi_strategy() */
  15870.   }
  15871.   
  15872.   
  15873. --- 166,172 ----
  15874.           screq->retsts = SCCMD_UNKNOWN;
  15875.           break;
  15876.       }
  15877. !     biodone(bp);     /* we're waiting on it in scsistrategy() */
  15878.   }
  15879.   
  15880.   
  15881. *** old-NetBSD/src/sys/sys/mount.h
  15882. --- NetBSD/src/sys/sys/mount.h
  15883. ***************
  15884. *** 380,388 ****
  15885.   struct adosfs_args {
  15886.       char    *fspec;        /* blocks special holding the fs to mount */
  15887.       struct    export_args export;    /* network export information */
  15888. !     uid_t    uid;        /* uid that owns msdosfs files */
  15889. !     gid_t    gid;        /* gid that owns msdosfs files */
  15890. !     mode_t    mask;        /* mask to be applied for msdosfs perms */
  15891.   };
  15892.   
  15893.   #ifdef _KERNEL
  15894. --- 380,388 ----
  15895.   struct adosfs_args {
  15896.       char    *fspec;        /* blocks special holding the fs to mount */
  15897.       struct    export_args export;    /* network export information */
  15898. !     uid_t    uid;        /* uid that owns adosfs files */
  15899. !     gid_t    gid;        /* gid that owns adosfs files */
  15900. !     mode_t    mask;        /* mask to be applied for adosfs perms */
  15901.   };
  15902.   
  15903.   #ifdef _KERNEL
  15904. *** old-NetBSD/src/sys/vm/swap_pager.c
  15905. --- NetBSD/src/sys/vm/swap_pager.c
  15906. ***************
  15907. *** 71,77 ****
  15908.   #endif
  15909.   
  15910.   #ifdef DEBUG
  15911. ! int    swpagerdebug = 0x100;
  15912.   #define    SDB_FOLLOW    0x001
  15913.   #define SDB_INIT    0x002
  15914.   #define SDB_ALLOC    0x004
  15915. --- 71,77 ----
  15916.   #endif
  15917.   
  15918.   #ifdef DEBUG
  15919. ! int    swpagerdebug = 0x000;
  15920.   #define    SDB_FOLLOW    0x001
  15921.   #define SDB_INIT    0x002
  15922.   #define SDB_ALLOC    0x004
  15923. *** old-NetBSD/src/usr.bin/kdump/kdump.c
  15924. --- NetBSD/src/usr.bin/kdump/kdump.c
  15925. ***************
  15926. *** 109,116 ****
  15927. --- 109,134 ----
  15928.       { NULL,                 NULL,            NULL }
  15929.   };
  15930.   
  15931. + struct emulation_map {
  15932. +     struct emulation_map *em_link;
  15933. +     pid_t             em_pid;
  15934. +     struct emulation     *em_emulation;
  15935. + };
  15936. + /* Forward decls. */
  15937. + struct emulation *emulation_from_name __P((char *name));
  15938. + struct emulation *emulation_from_pid __P((pid_t pid));
  15939. + void bind_emulation_to_pid __P((struct emulation *, pid_t));
  15940. + /* A mapping between pids and emulations currently in charge.  */
  15941. + struct emulation_map *current_emulations;
  15942. + /* The current emulation (cache during a single trace event).  */
  15943.   struct emulation *current;
  15944.   
  15945. + /* The default emulation, if nothing else is known.  */
  15946. + struct emulation *default_emulation;
  15947.   
  15948.   static char *ptrace_ops[] = {
  15949.       "PT_TRACE_ME",    "PT_READ_I",    "PT_READ_D",    "PT_READ_U",
  15950. ***************
  15951. *** 127,138 ****
  15952.       register void *m;
  15953.       int trpoints = ALL_POINTS;
  15954.   
  15955. !     current = &emulations[0];    /* NetBSD */
  15956.   
  15957.       while ((ch = getopt(argc, argv, "e:f:dlm:nRTt:")) != -1)
  15958.           switch (ch) {
  15959.           case 'e':
  15960. !             setemul(optarg);
  15961.               break;
  15962.           case 'f':
  15963.               tracefile = optarg;
  15964. --- 145,156 ----
  15965.       register void *m;
  15966.       int trpoints = ALL_POINTS;
  15967.   
  15968. !     default_emulation = &emulations[0];    /* NetBSD */
  15969.   
  15970.       while ((ch = getopt(argc, argv, "e:f:dlm:nRTt:")) != -1)
  15971.           switch (ch) {
  15972.           case 'e':
  15973. !             default_emulation = emulation_from_name(optarg);
  15974.               break;
  15975.           case 'f':
  15976.               tracefile = optarg;
  15977. ***************
  15978. *** 175,180 ****
  15979. --- 193,199 ----
  15980.       if (!freopen(tracefile, "r", stdin))
  15981.           err(1, "%s", tracefile);
  15982.       while (fread_tail(&ktr_header, sizeof(struct ktr_header), 1)) {
  15983. +         current = emulation_from_pid(ktr_header.ktr_pid);
  15984.           if (trpoints & (1<<ktr_header.ktr_type))
  15985.               dumpheader(&ktr_header);
  15986.           if ((ktrlen = ktr_header.ktr_len) < 0)
  15987. ***************
  15988. *** 209,215 ****
  15989.               ktrcsw((struct ktr_csw *)m);
  15990.               break;
  15991.           case KTR_EMUL:
  15992. !             ktremul(m, ktrlen);
  15993.               break;
  15994.           }
  15995.           if (tail)
  15996. --- 228,234 ----
  15997.               ktrcsw((struct ktr_csw *)m);
  15998.               break;
  15999.           case KTR_EMUL:
  16000. !             ktremul(m, ktrlen, ktr_header.ktr_pid);
  16001.               break;
  16002.           }
  16003.           if (tail)
  16004. ***************
  16005. *** 378,385 ****
  16006.       (void)printf("\"%.*s\"\n", len, cp);
  16007.   }
  16008.   
  16009. ! ktremul(cp, len) 
  16010.       char *cp;
  16011.   {
  16012.       char name[1024];
  16013.   
  16014. --- 397,405 ----
  16015.       (void)printf("\"%.*s\"\n", len, cp);
  16016.   }
  16017.   
  16018. ! ktremul(cp, len, pid) 
  16019.       char *cp;
  16020. +     pid_t pid;
  16021.   {
  16022.       char name[1024];
  16023.   
  16024. ***************
  16025. *** 390,396 ****
  16026.       name[len] = '\0';
  16027.       (void)printf("\"%s\"\n", name);
  16028.   
  16029. !     setemul(name);
  16030.   }
  16031.   
  16032.   ktrgenio(ktr, len)
  16033. --- 410,416 ----
  16034.       name[len] = '\0';
  16035.       (void)printf("\"%s\"\n", name);
  16036.   
  16037. !     bind_emulation_to_pid(emulation_from_name(name), pid);
  16038.   }
  16039.   
  16040.   ktrgenio(ktr, len)
  16041. ***************
  16042. *** 481,494 ****
  16043.       exit(1);
  16044.   }
  16045.   
  16046. ! setemul(name)
  16047.       char *name;
  16048.   {
  16049.       int i;
  16050.       for (i = 0; emulations[i].name != NULL; i++)
  16051.           if (strcmp(emulations[i].name, name) == 0) {
  16052. !             current = &emulations[i];
  16053. !             return;
  16054.           }
  16055.       warnx("Emulation `%s' unknown", name);
  16056.   }
  16057. --- 501,549 ----
  16058.       exit(1);
  16059.   }
  16060.   
  16061. ! struct emulation *
  16062. ! emulation_from_name(name)
  16063.       char *name;
  16064.   {
  16065.       int i;
  16066.       for (i = 0; emulations[i].name != NULL; i++)
  16067.           if (strcmp(emulations[i].name, name) == 0) {
  16068. !             return &emulations[i];
  16069.           }
  16070.       warnx("Emulation `%s' unknown", name);
  16071. +     return default_emulation;
  16072. + }
  16073. + struct emulation *
  16074. + emulation_from_pid(pid)
  16075. +     pid_t pid;
  16076. + {
  16077. +     struct emulation_map *entry;
  16078. +     for (entry = current_emulations; entry; entry = entry->em_link)
  16079. +         if (entry->em_pid == pid)
  16080. +             return entry->em_emulation;
  16081. +     return default_emulation;
  16082. + }
  16083. + void
  16084. + bind_emulation_to_pid(emulation, pid)
  16085. +     struct emulation *emulation;
  16086. +     pid_t            pid;
  16087. + {
  16088. +     struct emulation_map *entry;
  16089. +     for (entry = current_emulations; entry; entry = entry->em_link)
  16090. +         if (entry->em_pid == pid) {
  16091. +             entry->em_emulation = emulation;
  16092. +             return;
  16093. +         }
  16094. +     entry = current_emulations;
  16095. +     current_emulations =
  16096. +         (struct emulation_map *)malloc(sizeof(struct emulation_map));
  16097. +     if (current_emulations == NULL)
  16098. +         errx(1, "%s", strerror(ENOMEM));
  16099. +     current_emulations->em_link = entry;
  16100. +     current_emulations->em_pid = pid;
  16101. +     current_emulations->em_emulation = emulation;
  16102.   }
  16103.